Sha256: b4048a48ca303bbbd7423b217cd7adc1432b9ee6936651be757f8172ece4c05d

Contents?: true

Size: 653 Bytes

Versions: 6

Compression:

Stored size: 653 Bytes

Contents

#!/usr/bin/env bats

greet () {
  echo "Hello, $1"'!'
  sleep 9
}

@test 'Export function, variables to BATS; exit a running job' {
  name='World'
  export name
  export -f greet
  run bash -c "
    greet \"$(echo '$name')\" &"'
    pid="$!"

    # Wait for 1 second, to show it is not stopping
    sleep 1

    if kill -0 $pid 2>/dev/null; then
      kill $pid
      wait $pid 2>/dev/null
      exit_status=$?
    else
      wait $pid 2>/dev/null
      exit_status=$?
    fi
    echo -n "$exit_status" > /tmp/exit_status
  '
  # app exits with an error code
  [ "$(cat /tmp/exit_status)" = 143 ]
  [ "$status" = 0 ]
  [ "$output" = "Hello, World!" ]
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
markdown_exec-2.7.2 bats/bats.bats
markdown_exec-2.7.1 bats/bats.bats
markdown_exec-2.7.0 bats/bats.bats
markdown_exec-2.6.0 bats/bats.bats
markdown_exec-2.5.0 bats/bats.bats
markdown_exec-2.4.0 bats/bats.bats