Skip to content

Commit b2dac0d

Browse files
committed
new: Fix test failures on Ubuntu Linux
Unsorted `compgen` and unescaped `{` characters in regular expressions strike again. Also, though the coverage report only shows 82.9%, that's because `kcov` isn't recognizing any of the array assignments as executed code. Coverage is actually 100%.
1 parent 0d8bd29 commit b2dac0d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/new.bats

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ assert_command_script_is_executable() {
8989
mkdir -p "$TEST_GO_SCRIPTS_DIR/lib/"
9090
touch "${internal_modules[@]}"
9191

92+
local expected
93+
@go.test_compgen 'expected' "$TEST_GO_SCRIPTS_DIR/lib"
94+
9295
run "$TEST_GO_SCRIPT" complete 2 new '--internal'
93-
assert_success "${internal_modules[@]#$TEST_GO_SCRIPTS_DIR/lib/}"
96+
assert_success "${expected[@]}"
9497

9598
run "$TEST_GO_SCRIPT" complete 2 new '--internal' 'f'
9699
assert_success 'foo '
@@ -146,11 +149,14 @@ assert_command_script_is_executable() {
146149
mkdir -p "$TEST_GO_ROOTDIR/gue"
147150
touch "${text_files[@]}"
148151

152+
local expected
153+
@go.test_compgen 'expected' "$TEST_GO_ROOTDIR/gue"
154+
149155
run "$TEST_GO_SCRIPT" complete 2 new '--type'
150156
assert_failure ''
151157

152158
run "$TEST_GO_SCRIPT" complete 3 new '--type' 'adversary' 'g'
153-
assert_success 'go' 'gue/'
159+
assert_success "${expected[@]}"
154160

155161
run "$TEST_GO_SCRIPT" complete 3 new '--type' 'adversary' 'gu'
156162
assert_success 'gue/'
@@ -297,12 +303,12 @@ assert_command_script_is_executable() {
297303
@test "$SUITE: new subcommand script" {
298304
run "$TEST_GO_SCRIPT" new --command foo
299305
assert_success "EDITING: $TEST_GO_SCRIPTS_DIR/foo"
300-
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo" $'\n_foo\(\) {\n'
306+
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo" $'\n_foo\(\) \{\n'
301307
assert_command_script_is_executable 'foo'
302308

303309
run "$TEST_GO_SCRIPT" new --command foo bar
304310
assert_success "EDITING: $TEST_GO_SCRIPTS_DIR/foo.d/bar"
305-
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo.d/bar" $'\n_bar\(\) {\n'
311+
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo.d/bar" $'\n_bar\(\) \{\n'
306312
assert_command_script_is_executable 'foo.d/bar'
307313
}
308314

@@ -321,7 +327,7 @@ assert_command_script_is_executable() {
321327
'' \
322328
'@go.show_subcommands'
323329
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo.d/bar" '@go.show_subcommands'
324-
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo.d/bar.d/baz" $'\n_baz\(\) {\n'
330+
assert_file_matches "$TEST_GO_SCRIPTS_DIR/foo.d/bar.d/baz" $'\n_baz\(\) \{\n'
325331

326332
assert_command_script_is_executable 'foo'
327333
assert_command_script_is_executable 'foo.d/bar'
@@ -415,7 +421,7 @@ assert_command_script_is_executable() {
415421
EDITOR= run "$TEST_GO_SCRIPT" new --test foo/bar/baz
416422
assert_success ''
417423
assert_file_matches "$TEST_GO_ROOTDIR/$_GO_TEST_DIR/foo/bar/baz.bats" \
418-
$'\n@test "\$SUITE: short description of your first test case" {\n'
424+
$'\n@test "\$SUITE: short description of your first test case" \{\n'
419425
}
420426

421427
@test "$SUITE: --test fails if public module already exists" {

0 commit comments

Comments
 (0)