tests
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
setup() {
|
||||
echo "start $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo "end $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "test 1" {
|
||||
# stretch the time this test runs to prevent accidental serialization by the scheduler
|
||||
# if both tests could run in parallel, this will increase the likelihood of detecting it
|
||||
# by delaying this test's teardown past the other's
|
||||
sleep 3
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
setup() {
|
||||
echo "start $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo "end $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "test 2" {
|
||||
run cat "$FILE_MARKER"
|
||||
echo "$output"
|
||||
|
||||
# assuming serialized, ordered execution we will always see the first test start and end before this runs
|
||||
[[ "${lines[0]}" == "start"* ]]
|
||||
OTHER_TEST_NAME="${lines[0]:6}"
|
||||
[[ "$OTHER_TEST_NAME" != "$BATS_TEST_NAME" ]]
|
||||
[[ "${lines[1]}" == "end $OTHER_TEST_NAME" ]]
|
||||
[[ "${lines[2]}" == "start $BATS_TEST_NAME" ]]
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
setup_file() {
|
||||
export FILE_MARKER
|
||||
FILE_MARKER=$(mktemp "${BATS_RUN_TMPDIR}/file_marker.XXXXXX")
|
||||
if [[ -n "${DISABLE_IN_SETUP_FILE_FUNCTION:-}" ]]; then
|
||||
export BATS_NO_PARALLELIZE_WITHIN_FILE=true
|
||||
echo "setup_file() sets BATS_NO_PARALLELIZE_WITHIN_FILE=true" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -n "${DISABLE_OUTSIDE_ALL_FUNCTIONS:-}" ]]; then
|
||||
export BATS_NO_PARALLELIZE_WITHIN_FILE=true
|
||||
echo "File sets BATS_NO_PARALLELIZE_WITHIN_FILE=true" >&2
|
||||
fi
|
||||
|
||||
teardown_file() {
|
||||
rm "$FILE_MARKER"
|
||||
}
|
||||
|
||||
setup() {
|
||||
if [[ -n "${DISABLE_IN_SETUP_FUNCTION:-}" ]]; then
|
||||
export BATS_NO_PARALLELIZE_WITHIN_FILE=true
|
||||
echo "setup() sets BATS_NO_PARALLELIZE_WITHIN_FILE=true" >&3
|
||||
fi
|
||||
echo "start $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo "end $BATS_TEST_NAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "test 1" {
|
||||
if [[ -n "${DISABLE_IN_TEST_FUNCTION:-}" ]]; then
|
||||
export BATS_NO_PARALLELIZE_WITHIN_FILE=true
|
||||
echo "Test function sets BATS_NO_PARALLELIZE_WITHIN_FILE=true" >&3
|
||||
fi
|
||||
# stretch the time this test runs to prevent accidental serialization by the scheduler
|
||||
# if both tests could run in parallel, this will increase the likelihood of detecting it
|
||||
# by delaying this test's teardown past the other's
|
||||
sleep 3
|
||||
}
|
||||
|
||||
@test "test 2" {
|
||||
run cat "$FILE_MARKER"
|
||||
echo "$output"
|
||||
|
||||
# assuming serialized, ordered execution we will always see the first test start and end before this runs
|
||||
[[ "${lines[0]}" == "start"* ]]
|
||||
OTHER_TEST_NAME="${lines[0]:6}"
|
||||
[[ "$OTHER_TEST_NAME" != "$BATS_TEST_NAME" ]]
|
||||
[[ "${lines[1]}" == "end $OTHER_TEST_NAME" ]]
|
||||
[[ "${lines[2]}" == "start $BATS_TEST_NAME" ]]
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
setup_file() {
|
||||
export OTHER_ENV_VARIABLE='my-value'
|
||||
}
|
||||
|
||||
@test "check env variables are set" {
|
||||
[[ "$TEST_ENV_VARIABLE" == "test-value" ]]
|
||||
[[ "$OTHER_ENV_VARIABLE" == "my-value" ]]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
setup() {
|
||||
load '../../concurrent-coordination'
|
||||
echo "start $BATS_TEST_NAME $BATS_TEST_FILENAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo "stop $BATS_TEST_NAME $BATS_TEST_FILENAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "slow test 1" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 2" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 3" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
setup() {
|
||||
load '../../concurrent-coordination'
|
||||
echo setup "$BATS_TEST_NUMBER" >>"${MARKER_FILE?}"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo teardown "$BATS_TEST_NUMBER" >>"${MARKER_FILE?}"
|
||||
}
|
||||
|
||||
@test "slow test 1" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 2" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 3" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 4" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 5" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 6" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 7" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 8" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 9" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 10" {
|
||||
single-use-barrier "parallel_factor" "$PARALLELITY"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
setup_file() {
|
||||
load '../../../concurrent-coordination'
|
||||
echo "start $BATS_TEST_FILENAME" >>"${FILE_MARKER?}"
|
||||
single-use-barrier setup-file "${PARALLELITY?}" 10
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
echo "stop $BATS_TEST_FILENAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "nothing" {
|
||||
true
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
./setup_file.bats
|
||||
+1
@@ -0,0 +1 @@
|
||||
./setup_file.bats
|
||||
+1
@@ -0,0 +1 @@
|
||||
./setup_file.bats
|
||||
@@ -0,0 +1,20 @@
|
||||
setup() {
|
||||
load '../../../concurrent-coordination'
|
||||
echo "start $BATS_TEST_NAME $BATS_TEST_FILENAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
echo "stop $BATS_TEST_NAME $BATS_TEST_FILENAME" >>"$FILE_MARKER"
|
||||
}
|
||||
|
||||
@test "slow test 1" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 2" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
|
||||
@test "slow test 3" {
|
||||
single-use-barrier "parallel" "$PARALLELITY"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
parallel1.bats
|
||||
+1
@@ -0,0 +1 @@
|
||||
parallel1.bats
|
||||
+1
@@ -0,0 +1 @@
|
||||
parallel1.bats
|
||||
Reference in New Issue
Block a user