From: Jo-Philipp Wich Date: Wed, 1 Sep 2021 13:27:21 +0000 (+0200) Subject: tests: adapt to latest ucode X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c9a3bf5929c33aea3685c6a61ce18f83c4c8e66a;p=project%2Ffirewall4.git tests: adapt to latest ucode - Environment must be set before preloading and executing modules - Caching of fs module must be inhibited - Mocklib class object should be returned Signed-off-by: Jo-Philipp Wich --- diff --git a/run_tests.sh b/run_tests.sh index 8f0c293..2bdefbd 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -70,12 +70,12 @@ run_testcase() { local code=$7 local fail=0 - ucode -m mocklib -m fw4 ${uenv:+-e "$uenv"} -e '{ + ucode ${uenv:+-e "$uenv"} -e '{ "MOCK_SEARCH_PATH": [ "'"$dir"'/files", "./tests/mocks" ] - }' ${env:+-e "$(cat "$env")"} -i - <"$in" >"$dir/res.out" 2>"$dir/res.err" + }' ${env:+-e "$(cat "$env")"} -m mocklib -m fw4 -i - <"$in" >"$dir/res.out" 2>"$dir/res.err" printf "%d\n" $? > "$dir/res.code" diff --git a/tests/lib/mocklib.uc b/tests/lib/mocklib.uc index db38022..bcbb740 100644 --- a/tests/lib/mocklib.uc +++ b/tests/lib/mocklib.uc @@ -1,6 +1,9 @@ {% let _fs = require("fs"); + /* Force reloading fs module on next require */ + delete global.modules.fs; + let _log = (level, fmt, ...args) => { let color, prefix; @@ -222,3 +225,5 @@ global.print(...args); }; + return global.mocklib; +