Skip to content

Commit 74ff7b6

Browse files
authored
Merge pull request #6150 from trws/docker-and-test-updates
add support for new wrap options in tests and heredoc support for sharness
2 parents 441a0df + b6cafb9 commit 74ff7b6

File tree

9 files changed

+97
-1
lines changed

9 files changed

+97
-1
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extend-exclude = [
1818
"t/hwloc-data/*",
1919
"doc/test/spell.en.pws",
2020
"t/resource/resource.eventlog.*",
21+
"t/sharness",
2122
]
2223

2324
[default.extend-words]

src/common/liboptparse/optparse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ double optparse_get_duration (optparse_t *p,
988988
if (fsd_parse_duration (s, &d) < 0) {
989989
optparse_fatalmsg (p,
990990
1,
991-
"%s: Invalid argument for option '%s': '%s'",
991+
"%s: Invalid argument for option '%s': '%s'\n",
992992
p->program_name,
993993
name,
994994
s);

src/test/docker/docker-run-checks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ else
231231
-e TAP_DRIVER_QUIET \
232232
-e FLUX_TEST_TIMEOUT \
233233
-e FLUX_TEST_SIZE_MAX \
234+
-e PYTHON \
234235
-e PYTHON_VERSION \
235236
-e PRELOAD \
236237
-e POISON \

t/sharness.d/flux-sharness.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ test_under_flux() {
253253
valgrind="$valgrind,--trace-children=no,--child-silent-after-fork=yes"
254254
valgrind="$valgrind,--leak-resolution=med,--error-exitcode=1"
255255
valgrind="$valgrind,--suppressions=${VALGRIND_SUPPRESSIONS}"
256+
elif test -n "$FLUX_TEST_HEAPTRACK" ; then
257+
valgrind="--wrap=heaptrack,--record-only"
258+
elif test -n "$FLUX_TEST_WRAP" ; then
259+
valgrind="$FLUX_TEST_WRAP"
256260
fi
257261
# Extend timeouts when running under AddressSanitizer
258262
if test_have_prereq ASAN; then

t/sharness.d/heredoc.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
test_expect_success_hd() {
2+
test "$#" = 2 && { test_prereq=$1; shift; } || test_prereq=
3+
local TEST_CODE
4+
# these extra newlines are intentional, and mimic the ones we get
5+
# naturally in the non-heredoc case
6+
TEST_CODE="\
7+
8+
$(cat)
9+
"
10+
test_expect_success "$test_prereq" "'$1'" "$TEST_CODE"
11+
}
12+
13+
test_expect_failure_hd() {
14+
test "$#" = 2 && { test_prereq=$1; shift; } || test_prereq=
15+
local TEST_CODE
16+
# these extra newlines are intentional, and mimic the ones we get
17+
# naturally in the non-heredoc case
18+
TEST_CODE="\
19+
20+
$(cat)
21+
"
22+
test_expect_failure "$test_prereq" "'$1'" "$TEST_CODE"
23+
}
24+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
au BufRead,BufNewFile *.t set filetype=sh.sharness

t/sharness/vim/indent/sharness.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let b:sh_indent_options = { 'continuation-line': 0 }
2+
3+
runtime! indent/sh.vim

t/sharness/vim/syntax/sharness.vim

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
let b:is_bash=1
2+
runtime! syntax/sh.vim
3+
4+
syn keyword shsStatement test_done
5+
syn keyword shsStatement test_set_editor test_set_index_version test_decode_color lf_to_nul nul_to_q q_to_nul q_to_cr q_to_tab qz_to_tab_space append_cr remove_cr generate_zero_bytes sane_unset test_tick test_pause debug test_commit test_merge test_commit_bulk test_chmod test_modebits test_unconfig test_config test_config_global write_script test_unset_prereq test_set_prereq test_have_prereq test_declared_prereq test_verify_prereq test_external test_external_without_stderr test_path_is_file test_path_is_dir test_path_exists test_dir_is_empty test_file_not_empty test_path_is_missing test_line_count test_file_size list_contains test_must_fail_acceptable test_must_fail test_might_fail test_expect_code test_i18ncmp test_i18ngrep verbose test_must_be_empty test_cmp_rev test_cmp_fspath test_seq test_when_finished test_atexit test_create_repo test_ln_s_add test_write_lines perl test_bool_env test_skip_or_die mingw_test_cmp test_env test_match_signal test_copy_bytes nongit depacketize hex2oct test_set_hash test_detect_hash test_oid_init test_oid_cache test_oid test_oid_to_path test_set_port test_bitmap_traversal test_path_is_hidden test_subcommand
6+
syn keyword shsStatement test_cmp test_cmp_config test_cmp_bin packetize
7+
8+
syn region shsTest fold start="\<test_expect_\w\+\(_hd\)\?\>" end="$" contains=shsTestTitle
9+
syn region shsTest fold start="\<test_expect_\w\+\(_hd\)\?\>\s\+\<[A-Z_,]\+\>" end="$" contains=shsPrereq
10+
syn region shsTest fold start="\<test_lazy_prereq\>\s\+\<[A-Z_,]\+\>" end="$" contains=shsPrereqLazy
11+
12+
syn keyword shsTestStatement contained containedin=shsTest test_expect_success test_expect_failure test_expect_unstable test_lazy_prereq test_expect_success_hd test_expect_failure_hd test_expect_unstable_hd
13+
14+
syn region shsTestTitle contained start=' 'hs=s+1 end=' 'me=e-1 nextgroup=shsTestBody contains=shSingleQuote,shDoubleQuote
15+
16+
" multiple line body
17+
syn region shsTestBody contained transparent excludenl matchgroup=shQuote start=+ '\\\?$+hs=s+1,rs=e end=+'$+ contains=@shSubShList
18+
syn region shsTestBody contained transparent excludenl matchgroup=shQuote start=+ "\\\?$+hs=s+1,rs=e end=+"$+ contains=@shSubShList
19+
syn region shsTestBody contained transparent excludenl matchgroup=shHDBody start=+ <<-\?'\z(\w\+\)'$+hs=e,rs=e end=+^\s*\z2$+ contains=@shSubShList
20+
21+
" single line body
22+
syn region shsTestBody contained oneline transparent excludenl keepend matchgroup=shQuote start=+ '+hs=s+1 end=+'$+ contains=@shSubShList
23+
syn region shsTestBody contained oneline transparent excludenl keepend matchgroup=shQuote start=+ "+hs=s+1 end=+"$+ contains=@shSubShList
24+
25+
" heredoc quotes
26+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\"\z(.\{-1,\}\)\\\"" matchgroup=shRedir end="^\z1\s*$"
27+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\"\z(.\{-1,\}\)\\\"" matchgroup=shRedir end="^\s*\z1\s*$"
28+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\\\z([^ \t|>]\+\)" matchgroup=shRedir end="^\z1\s*$"
29+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\\\z([^ \t|>]\+\)" matchgroup=shRedir end="^\s*\z1\s*$"
30+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shRedir end="^\z1\s*$" contains=@shDblQuoteList
31+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shRedir end="^\s*\z1\s*$" contains=@shDblQuoteList
32+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\\\_$\_s*\\\\\z([^ \t|>]\+\)" matchgroup=shRedir end="^\z1\s*$"
33+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\\\_$\_s*\\\\\z([^ \t|>]\+\)" matchgroup=shRedir end="^\s*\z1\s*$"
34+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\\\_$\_s*'\z(.\{-1,\}\)'" matchgroup=shRedir end="^\z1\s*$"
35+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\\\_$\_s*'\z(.\{-1,\}\)'" matchgroup=shRedir end="^\s*\z1\s*$"
36+
syn region shHereDoc matchgroup=shRedir start="<<\s*\\\\\_$\_s*\\\"\z(.\{-1,\}\)\\\"" matchgroup=shRedir end="^\z1\s*$"
37+
syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\\\_$\_s*\\\"\z(.\{-1,\}\)\\\"" matchgroup=shRedir end="^\s*\z1\s*$"
38+
39+
syn match shsPrereq contained "\<[A-Z_,]\+\>" nextgroup=shsTestTitle
40+
syn match shsPrereqLazy contained "\<[A-Z_,]\+\>" nextgroup=shsTestBody
41+
42+
syn cluster shCommandSubList add=shsTest,shsStatement
43+
44+
hi def link shsStatement Statement
45+
hi def link shsTestStatement Function
46+
hi def link shsPrereq Identifier
47+
hi def link shsPrereqLazy shsPrereq
48+
hi def link shsTestBody shRedir
49+
50+
let b:current_syntax='sharness'

t/t0001-basic.t

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ path_printenv=$(which printenv)
2424
test_expect_success 'TEST_NAME is set' '
2525
test -n "$TEST_NAME"
2626
'
27+
test_expect_success_hd 'heredoc tests work: success' <<-'EOT'
28+
test -n "$TEST_NAME" &&
29+
# embedded heredoc
30+
cat >tmp.sh <<-EOF &&
31+
true
32+
EOF
33+
chmod +x tmp.sh &&
34+
./tmp.sh
35+
EOT
36+
test_expect_failure_hd 'heredoc tests work: failure' <<'EOT'
37+
test -n ""
38+
EOT
2739
test_expect_success 'run_timeout works' '
2840
test_expect_code 142 run_timeout -s ALRM 0.001 sleep 2
2941
'

0 commit comments

Comments
 (0)