From 3ab495fda2e032b869eee86b262e651ff907c9c5 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Wed, 15 Feb 2017 12:04:03 -0500 Subject: [PATCH] preprocess: Add tests for vars, quotes in names This is in anticipation of refactoring away the `$(eval echo "$quoted_name")` command substitution. --- test/bats.bats | 14 ++++++++++++++ test/fixtures/bats/expand_var_in_test_name.bats | 3 +++ .../bats/quoted_and_unquoted_test_names.bats | 11 +++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/fixtures/bats/expand_var_in_test_name.bats create mode 100644 test/fixtures/bats/quoted_and_unquoted_test_names.bats diff --git a/test/bats.bats b/test/bats.bats index 9fca64a..60fb017 100755 --- a/test/bats.bats +++ b/test/bats.bats @@ -268,3 +268,17 @@ fixtures bats [ $status -eq 0 ] [ "${lines[1]}" = "ok 1 loop_func" ] } + +@test "expand variables in test name" { + SUITE='test/suite' run bats "$FIXTURE_ROOT/expand_var_in_test_name.bats" + [ $status -eq 0 ] + [ "${lines[1]}" = "ok 1 test/suite: test with variable in name" ] +} + +@test "handle quoted and unquoted test names" { + run bats "$FIXTURE_ROOT/quoted_and_unquoted_test_names.bats" + [ $status -eq 0 ] + [ "${lines[1]}" = "ok 1 single-quoted name" ] + [ "${lines[2]}" = "ok 2 double-quoted name" ] + [ "${lines[3]}" = "ok 3 unquoted" ] +} diff --git a/test/fixtures/bats/expand_var_in_test_name.bats b/test/fixtures/bats/expand_var_in_test_name.bats new file mode 100644 index 0000000..8f6dec2 --- /dev/null +++ b/test/fixtures/bats/expand_var_in_test_name.bats @@ -0,0 +1,3 @@ +@test "$SUITE: test with variable in name" { + true +} diff --git a/test/fixtures/bats/quoted_and_unquoted_test_names.bats b/test/fixtures/bats/quoted_and_unquoted_test_names.bats new file mode 100644 index 0000000..706902b --- /dev/null +++ b/test/fixtures/bats/quoted_and_unquoted_test_names.bats @@ -0,0 +1,11 @@ +@test 'single-quoted name' { + true +} + +@test "double-quoted name" { + true +} + +@test unquoted { + true +}