From e42e4fce9484a860c02ad29ff41eacf976e7f949 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 01:09:04 -0500 Subject: [PATCH 01/24] Add functions for listing names of defined functions and variables --- mo | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/mo b/mo index c928d7c..eeb11ed 100755 --- a/mo +++ b/mo @@ -1095,6 +1095,54 @@ moUsage() { } +# Produce a list of all shell function declared by mo, and brought +# into any shell that had sourced the file. Each name is given on one +# line of standard output. +moListFuncs() { + cat < Date: Mon, 24 Jan 2022 01:09:19 -0500 Subject: [PATCH 02/24] Add functions for handling defined functions and variables --- mo | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/mo b/mo index eeb11ed..38d18bb 100755 --- a/mo +++ b/mo @@ -1128,6 +1128,10 @@ moTrimWhitespace moUsage moListFuncs moListVars +moUnload +moExport +moUnexport +moDeclare EOF } @@ -1139,13 +1143,63 @@ moListVars() { cat < Date: Mon, 24 Jan 2022 17:55:54 -0500 Subject: [PATCH 03/24] Fix formatting of white space in test output --- run-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests b/run-tests index b1a0331..507678b 100755 --- a/run-tests +++ b/run-tests @@ -38,7 +38,7 @@ for TEST in tests/*.expected; do done echo "" -echo "Pass: $PASS" +echo "Pass: $PASS" echo "Fail: $FAIL" if [[ $FAIL -gt 0 ]]; then exit 1 From 343135760ccb7375ff3bc937e4350cc20d5ed72b Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:36:46 -0500 Subject: [PATCH 04/24] Fortify detection of base directory for tests --- run-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests b/run-tests index 507678b..f1a8d21 100755 --- a/run-tests +++ b/run-tests @@ -1,6 +1,6 @@ #!/usr/bin/env bash -cd "${0%/*}" || exit 1 +cd "$(dirname "$0")" || exit 1 # shellcheck disable=SC1091 . ./mo From ed2ab8f2a6122f42320761cad059ed9137da2e68 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:01:38 -0500 Subject: [PATCH 05/24] Move loop over tests to separate file --- run-basic-tests | 33 +++++++++++++++++++++++++++++++++ run-tests | 30 +----------------------------- 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100755 run-basic-tests diff --git a/run-basic-tests b/run-basic-tests new file mode 100755 index 0000000..8e04e20 --- /dev/null +++ b/run-basic-tests @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" || exit 1 + +for TEST in tests/*.expected; do + export BASE="${TEST%.expected}" + export MO_FALSE_IS_EMPTY= + + echo -n "$BASE ... " + + ( + if [[ -f "${BASE}.sh" ]]; then + # Run a shell script if one exists + "${BASE}.sh" + else + # Fall back to using .env and .template + # shellcheck disable=SC1090 + . "${BASE}.env" + echo "Do not read this input" | mo "${BASE}.template" + fi + ) | diff -U5 - "${TEST}" > "${BASE}.diff" + + statusCode=$? + + if [[ $statusCode -ne 0 ]]; then + echo "FAIL (status code $statusCode)" + FAIL=$(( FAIL + 1 )) + else + echo "ok" + PASS=$(( PASS + 1 )) + rm "${BASE}.diff" + fi +done diff --git a/run-tests b/run-tests index f1a8d21..e5016f3 100755 --- a/run-tests +++ b/run-tests @@ -7,35 +7,7 @@ cd "$(dirname "$0")" || exit 1 PASS=0 FAIL=0 -for TEST in tests/*.expected; do - export BASE="${TEST%.expected}" - export MO_FALSE_IS_EMPTY= - - echo -n "$BASE ... " - - ( - if [[ -f "${BASE}.sh" ]]; then - # Run a shell script if one exists - "${BASE}.sh" - else - # Fall back to using .env and .template - # shellcheck disable=SC1090 - . "${BASE}.env" - echo "Do not read this input" | mo "${BASE}.template" - fi - ) | diff -U5 - "${TEST}" > "${BASE}.diff" - - statusCode=$? - - if [[ $statusCode -ne 0 ]]; then - echo "FAIL (status code $statusCode)" - FAIL=$(( FAIL + 1 )) - else - echo "ok" - PASS=$(( PASS + 1 )) - rm "${BASE}.diff" - fi -done +source ./run-basic-tests echo "" echo "Pass: $PASS" From 67bd586575e1623fa98f5fded0f073db36617f30 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:01:59 -0500 Subject: [PATCH 06/24] Print prefix `basic` before test name instead of file relative path --- run-basic-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-basic-tests b/run-basic-tests index 8e04e20..b7c4580 100755 --- a/run-basic-tests +++ b/run-basic-tests @@ -6,7 +6,7 @@ for TEST in tests/*.expected; do export BASE="${TEST%.expected}" export MO_FALSE_IS_EMPTY= - echo -n "$BASE ... " + echo -n "basic:${BASE#tests/} ... " ( if [[ -f "${BASE}.sh" ]]; then From 3cd32a4a0ed5e67bc46a5871711a3bf9289ad8bc Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:04:49 -0500 Subject: [PATCH 07/24] Add `meta` tests, to validate handling of functions for subshells --- meta-tests.txt | 0 run-meta-tests | 23 +++++++++++++++++++++++ run-tests | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 meta-tests.txt create mode 100644 run-meta-tests diff --git a/meta-tests.txt b/meta-tests.txt new file mode 100644 index 0000000..e69de29 diff --git a/run-meta-tests b/run-meta-tests new file mode 100644 index 0000000..3af69f0 --- /dev/null +++ b/run-meta-tests @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" || exit 1 + +for TEST in $(cat meta-tests.txt); do + + echo -n "meta:$TEST ... " + + ( + meta-tests/${TEST}.sh > /dev/null 2> /dev/null + ) + + statusCode=$? + + if [[ $statusCode -ne 0 ]]; then + echo "FAIL (status code $statusCode)" + FAIL=$(( FAIL + 1 )) + else + echo "ok" + PASS=$(( PASS + 1 )) + fi + +done diff --git a/run-tests b/run-tests index e5016f3..33889b7 100755 --- a/run-tests +++ b/run-tests @@ -9,6 +9,8 @@ FAIL=0 source ./run-basic-tests +source ./run-meta-tests + echo "" echo "Pass: $PASS" echo "Fail: $FAIL" From 8aeb20b1c028a23d92d093096760086d6b00d827 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:39:34 -0500 Subject: [PATCH 08/24] Add trivial test, for basic integrity of framework --- meta-tests.txt | 1 + meta-tests/base.sh | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100755 meta-tests/base.sh diff --git a/meta-tests.txt b/meta-tests.txt index e69de29..df967b9 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -0,0 +1 @@ +base diff --git a/meta-tests/base.sh b/meta-tests/base.sh new file mode 100755 index 0000000..64b6008 --- /dev/null +++ b/meta-tests/base.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +source ./mo +if (( FAIL )); then + exit 1 +fi From 61151b307bd0f4ab94504541650e1a7f8ea198c2 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:07:11 -0500 Subject: [PATCH 09/24] Add test that functions are not normally inherited --- meta-tests.txt | 1 + meta-tests/subshell-simple.sh | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100755 meta-tests/subshell-simple.sh diff --git a/meta-tests.txt b/meta-tests.txt index df967b9..1762ded 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -1 +1,2 @@ base +subshell-simple diff --git a/meta-tests/subshell-simple.sh b/meta-tests/subshell-simple.sh new file mode 100755 index 0000000..6e874bd --- /dev/null +++ b/meta-tests/subshell-simple.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source ./mo +bash << "EOF" +source ./run-basic-tests +if ! (( FAIL )); then + exit 1 +fi +EOF From 0036b48238d40a74fc108cf4fb53f576984a4e02 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:26:06 -0500 Subject: [PATCH 10/24] Add trivial test, that processing fails when tool is not invoked --- meta-tests.txt | 1 + meta-tests/subshell-undeclared.sh | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100755 meta-tests/subshell-undeclared.sh diff --git a/meta-tests.txt b/meta-tests.txt index 1762ded..de6e30f 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -1,2 +1,3 @@ base subshell-simple +subshell-undeclared diff --git a/meta-tests/subshell-undeclared.sh b/meta-tests/subshell-undeclared.sh new file mode 100755 index 0000000..da66a32 --- /dev/null +++ b/meta-tests/subshell-undeclared.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +bash << "EOF" +source ./run-basic-tests +if ! (( FAIL )); then + exit 1 +fi +EOF From 9ad445e280e3d8d7a5ce94c3d3ba08dd8d185626 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 17:14:51 -0500 Subject: [PATCH 11/24] Add test that functions run in child if explicitly imported --- meta-tests.txt | 1 + meta-tests/subshell-source.sh | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100755 meta-tests/subshell-source.sh diff --git a/meta-tests.txt b/meta-tests.txt index de6e30f..0ef16b2 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -1,3 +1,4 @@ base subshell-simple subshell-undeclared +subshell-source diff --git a/meta-tests/subshell-source.sh b/meta-tests/subshell-source.sh new file mode 100755 index 0000000..6edb3d9 --- /dev/null +++ b/meta-tests/subshell-source.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +bash << "EOF" +source ./mo +source ./run-basic-tests +if (( FAIL )); then + exit 1 +fi From cec3502e2207e19b6404b4e2f17ced38d5f17cbf Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 18:14:36 -0500 Subject: [PATCH 12/24] Add test that functions run in child if exported by parent --- meta-tests.txt | 1 + meta-tests/subshell-export.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100755 meta-tests/subshell-export.sh diff --git a/meta-tests.txt b/meta-tests.txt index 0ef16b2..86609f1 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -2,3 +2,4 @@ base subshell-simple subshell-undeclared subshell-source +subshell-export diff --git a/meta-tests/subshell-export.sh b/meta-tests/subshell-export.sh new file mode 100755 index 0000000..83147e0 --- /dev/null +++ b/meta-tests/subshell-export.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +source ./mo +moExport +bash << "EOF" +source ./run-basic-tests +if (( FAIL )); then + exit 1 +fi +EOF + From 61d6b0c6ef01ed601c45a7e8c559f16c876b491e Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 19:32:50 -0500 Subject: [PATCH 13/24] Add test that listed functions are the same as actually defined --- meta-tests.txt | 1 + meta-tests/function-list.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 meta-tests/function-list.sh diff --git a/meta-tests.txt b/meta-tests.txt index 86609f1..e8a55f4 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -3,3 +3,4 @@ subshell-simple subshell-undeclared subshell-source subshell-export +function-list diff --git a/meta-tests/function-list.sh b/meta-tests/function-list.sh new file mode 100755 index 0000000..cf38e4d --- /dev/null +++ b/meta-tests/function-list.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +list_function_names() { + declare -F | while read l; do echo ${l/#* /}; done | sort +} + +f_orig=$(list_function_names) + +source ./mo + +f=$(list_function_names) + +f_new=$(comm -13 <(echo $f_orig | tr ' ' '\n') <(echo $f | tr ' ' '\n')) + +diff <(echo $f_new | tr ' ' '\n') <(moListFuncs | sort) From 9a81e1d831a1e4b1b29925d66da11c7dce559a0c Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 19:32:50 -0500 Subject: [PATCH 14/24] Add test that defined functions are properly unloaded --- meta-tests.txt | 1 + meta-tests/function-unload.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100755 meta-tests/function-unload.sh diff --git a/meta-tests.txt b/meta-tests.txt index e8a55f4..64e86b5 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -4,3 +4,4 @@ subshell-undeclared subshell-source subshell-export function-list +function-unload diff --git a/meta-tests/function-unload.sh b/meta-tests/function-unload.sh new file mode 100755 index 0000000..263c8d7 --- /dev/null +++ b/meta-tests/function-unload.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +list_function_names() { + declare -F | while read l; do echo ${l/#* /}; done | sort +} + +f_orig=$(list_function_names) + +source ./mo +moUnload + +f=$(list_function_names) + +diff <(echo $f_orig | tr ' ' '\n') <(echo $f | tr ' ' '\n') From 747bb5932255d3a059073956fb974e215c0d5e37 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Tue, 25 Jan 2022 16:56:06 -0500 Subject: [PATCH 15/24] Add test that all declared functions are inherited when marked for export --- meta-tests.txt | 1 + meta-tests/function-export.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 meta-tests/function-export.sh diff --git a/meta-tests.txt b/meta-tests.txt index 64e86b5..4107891 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -5,3 +5,4 @@ subshell-source subshell-export function-list function-unload +function-export diff --git a/meta-tests/function-export.sh b/meta-tests/function-export.sh new file mode 100755 index 0000000..fb6ba3c --- /dev/null +++ b/meta-tests/function-export.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +list_function_names() { + declare -F | while read l; do echo ${l/#* /}; done | sort +} +declare -xf list_function_names + +f_orig=$(list_function_names) + +source ./mo +moExport + +f=$(bash -c list_function_names) + +f_new=$(comm -13 <(echo $f_orig | tr ' ' '\n') <(echo $f | tr ' ' '\n')) + +diff <(echo $f_new | tr ' ' '\n') <(moListFuncs | sort) From 88e7f092272eade700cc8a522ad0bcf39ec02d3e Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Tue, 25 Jan 2022 17:00:09 -0500 Subject: [PATCH 16/24] Add test that unmarking for export prevents inheritence by child shell --- meta-tests.txt | 1 + meta-tests/function-unexport.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 meta-tests/function-unexport.sh diff --git a/meta-tests.txt b/meta-tests.txt index 4107891..4792085 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -6,3 +6,4 @@ subshell-export function-list function-unload function-export +function-unexport diff --git a/meta-tests/function-unexport.sh b/meta-tests/function-unexport.sh new file mode 100755 index 0000000..5190c49 --- /dev/null +++ b/meta-tests/function-unexport.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +list_function_names() { + declare -F | while read l; do echo ${l/#* /}; done | sort +} +declare -xf list_function_names + +f_orig=$(list_function_names) + +source ./mo +moExport +moUnexport + +f=$(bash -c list_function_names) + +diff <(echo $f_orig | tr ' ' '\n') <(echo $f | tr ' ' '\n') From c4cd099d650e70343417377c5f8f9ef9b8898fe7 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Tue, 25 Jan 2022 16:31:53 -0500 Subject: [PATCH 17/24] Add test that subshell may process automatically-generated declarations --- meta-tests.txt | 1 + meta-tests/subshell-declare.sh | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100755 meta-tests/subshell-declare.sh diff --git a/meta-tests.txt b/meta-tests.txt index 4792085..93888c6 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -3,6 +3,7 @@ subshell-simple subshell-undeclared subshell-source subshell-export +subshell-declare function-list function-unload function-export diff --git a/meta-tests/subshell-declare.sh b/meta-tests/subshell-declare.sh new file mode 100755 index 0000000..9b6db40 --- /dev/null +++ b/meta-tests/subshell-declare.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source ./mo +cat <(moDeclare) - << "EOF" | bash +source ./run-basic-tests +if (( FAIL )); then + exit 1 +fi +EOF From 79231fad64f5755ea1b5cb1d1b123319e53fde02 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:12:54 -0500 Subject: [PATCH 18/24] Add test that declarations are not dependent on inherited environment --- meta-tests.txt | 1 + meta-tests/subshell-clean.sh | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100755 meta-tests/subshell-clean.sh diff --git a/meta-tests.txt b/meta-tests.txt index 93888c6..3c8980c 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -2,6 +2,7 @@ base subshell-simple subshell-undeclared subshell-source +subshell-clean subshell-export subshell-declare function-list diff --git a/meta-tests/subshell-clean.sh b/meta-tests/subshell-clean.sh new file mode 100755 index 0000000..c8fa996 --- /dev/null +++ b/meta-tests/subshell-clean.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source ./mo +cat <(moDeclare) - << "EOF" | env --ignore-environment bash +source ./run-basic-tests +if (( FAIL )); then + exit 1 +fi +EOF From 84edc13c1ef53e73c7f6bacc9f518c09cfede797 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:15:56 -0500 Subject: [PATCH 19/24] Add test that functions are not inherited into clean environment --- meta-tests.txt | 1 + meta-tests/subshell-clean-undeclared.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100755 meta-tests/subshell-clean-undeclared.sh diff --git a/meta-tests.txt b/meta-tests.txt index 3c8980c..0a9063d 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -3,6 +3,7 @@ subshell-simple subshell-undeclared subshell-source subshell-clean +subshell-clean-undeclared subshell-export subshell-declare function-list diff --git a/meta-tests/subshell-clean-undeclared.sh b/meta-tests/subshell-clean-undeclared.sh new file mode 100755 index 0000000..56ba131 --- /dev/null +++ b/meta-tests/subshell-clean-undeclared.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +source ./mo +moExport +env --ignore-environment << "EOF" +source ./run-basic-tests +if ! (( FAIL )); then + exit 1 +fi +EOF From b1d679b7b45c8286fd7f10231d9715b0dc28773e Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:19:50 -0500 Subject: [PATCH 20/24] Add test that unmarking functions for export indeed prevents exportation --- meta-tests.txt | 1 + meta-tests/subshell-unexport.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100755 meta-tests/subshell-unexport.sh diff --git a/meta-tests.txt b/meta-tests.txt index 0a9063d..60e75c5 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -5,6 +5,7 @@ subshell-source subshell-clean subshell-clean-undeclared subshell-export +subshell-unexport subshell-declare function-list function-unload diff --git a/meta-tests/subshell-unexport.sh b/meta-tests/subshell-unexport.sh new file mode 100755 index 0000000..b0c1fe5 --- /dev/null +++ b/meta-tests/subshell-unexport.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +source ./mo +moExport +moUnexport +bash << "EOF" +source ./run-basic-tests +if ! (( FAIL )); then + exit 1 +fi +EOF From 772eec96725d7dfa695b16aa9fc8c3f4c327782c Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:22:52 -0500 Subject: [PATCH 21/24] Add test that exported functions are inherited by descendants --- meta-tests.txt | 1 + meta-tests/subshell-export-nested.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 meta-tests/subshell-export-nested.sh diff --git a/meta-tests.txt b/meta-tests.txt index 60e75c5..9a86f42 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -5,6 +5,7 @@ subshell-source subshell-clean subshell-clean-undeclared subshell-export +subshell-export-nested subshell-unexport subshell-declare function-list diff --git a/meta-tests/subshell-export-nested.sh b/meta-tests/subshell-export-nested.sh new file mode 100755 index 0000000..e4cbd89 --- /dev/null +++ b/meta-tests/subshell-export-nested.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source ./mo +moExport +bash << "EOF" +bash << "EOF2" +bash << "EOF3" +bash << "EOF4" +source ./run-basic-tests +if (( FAIL )); then +exit 1 +fi +EOF4 +EOF3 +EOF2 +EOF From e1b775a9da74a7ccf30b601588168b7e4e345eb8 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 20:32:26 -0500 Subject: [PATCH 22/24] Add test that unmarking for export works in child shell from original --- meta-tests.txt | 1 + meta-tests/subshell-unexport-nested.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 meta-tests/subshell-unexport-nested.sh diff --git a/meta-tests.txt b/meta-tests.txt index 9a86f42..b7f378f 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -7,6 +7,7 @@ subshell-clean-undeclared subshell-export subshell-export-nested subshell-unexport +subshell-unexport-nested subshell-declare function-list function-unload diff --git a/meta-tests/subshell-unexport-nested.sh b/meta-tests/subshell-unexport-nested.sh new file mode 100755 index 0000000..9d0f2df --- /dev/null +++ b/meta-tests/subshell-unexport-nested.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +source ./mo +moExport +bash << "EOF" +moUnexport +bash << "EOF2" +source ./run-basic-tests +if ! (( FAIL )); then + exit 1 +fi +EOF2 +EOF From 5e04b21a7059811eed197f360a02971fea38d751 Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 22:13:47 -0500 Subject: [PATCH 23/24] Add test that declarations may be propagated to descedant shells --- meta-tests.txt | 1 + meta-tests/subshell-declare-nested.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 meta-tests/subshell-declare-nested.sh diff --git a/meta-tests.txt b/meta-tests.txt index b7f378f..7a48ab0 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -9,6 +9,7 @@ subshell-export-nested subshell-unexport subshell-unexport-nested subshell-declare +subshell-declare-nested function-list function-unload function-export diff --git a/meta-tests/subshell-declare-nested.sh b/meta-tests/subshell-declare-nested.sh new file mode 100755 index 0000000..5b385a9 --- /dev/null +++ b/meta-tests/subshell-declare-nested.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +source ./mo +cat <(moDeclare) - << "EOF" | bash +cat <(moDeclare) - << "EOF2" | bash +cat <(moDeclare) - << "EOF3" | bash +cat <(moDeclare) - << "EOF4" | bash +source ./run-basic-tests +if (( FAIL )); then + exit 1 +fi +EOF4 +EOF3 +EOF2 +EOF From a6771a6fb7642fb2a801eebb5e6fd0cb3663dcbb Mon Sep 17 00:00:00 2001 From: Eric Levy Date: Mon, 24 Jan 2022 22:24:34 -0500 Subject: [PATCH 24/24] Add test that generated usage function is equivalent to original --- meta-tests.txt | 1 + meta-tests/subshell-usage.sh | 4 ++++ 2 files changed, 5 insertions(+) create mode 100755 meta-tests/subshell-usage.sh diff --git a/meta-tests.txt b/meta-tests.txt index 7a48ab0..e94b65c 100644 --- a/meta-tests.txt +++ b/meta-tests.txt @@ -1,4 +1,5 @@ base +subshell-usage subshell-simple subshell-undeclared subshell-source diff --git a/meta-tests/subshell-usage.sh b/meta-tests/subshell-usage.sh new file mode 100755 index 0000000..32fc9c1 --- /dev/null +++ b/meta-tests/subshell-usage.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +source ./mo +diff <(moUsage) <((moDeclare; echo moUsage) | bash)