tests: run testcases in strict mode
authorJo-Philipp Wich <jo@mein.io>
Fri, 28 Jan 2022 10:54:19 +0000 (11:54 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 28 Jan 2022 11:06:01 +0000 (12:06 +0100)
Since /sbin/fw4 invokes ucode in strict mode, we should do the same in
test cases.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
run_tests.sh
tests/lib/mocklib.uc
tests/lib/mocklib/uci.uc

index 2bdefbd5029cbd09136ca61ba3ab458755afbdf1..dcc680215305fdc60221d7c1d0cc3431796cafe3 100755 (executable)
@@ -70,7 +70,7 @@ run_testcase() {
        local code=$7
        local fail=0
 
-       ucode ${uenv:+-e "$uenv"} -e '{
+       ucode -S ${uenv:+-e "$uenv"} -e '{
                "MOCK_SEARCH_PATH": [
                        "'"$dir"'/files",
                        "./tests/mocks"
index bcbb74054a42458695ea3691b28d6e865c41d0bf..5441bfbffe824644afb08cf8942292f544e140b3 100644 (file)
@@ -1,4 +1,14 @@
 {%
+       /* strict mode compliance: ensure that global variabes are defined */
+       if (!exists(global, 'REQUIRE_SEARCH_PATH'))
+               global.MOCK_SEARCH_PATH = null;
+
+       if (!exists(global, 'MOCK_SEARCH_PATH'))
+               global.MOCK_SEARCH_PATH = null;
+
+       if (!exists(global, 'TRACE_CALLS'))
+               global.TRACE_CALLS = null;
+
        let _fs = require("fs");
 
        /* Force reloading fs module on next require */
index 542eeb87f0ce75e698c7f5e21ddce08131e31bda..69d25615faaaee94c23e8e06cb9ea1ebc0f18715 100644 (file)
@@ -23,6 +23,7 @@
 
        let fixup_config = (config) => {
                let rv = {};
+               let n_section = 0;
 
                for (let stype in config) {
                        switch (type(config[stype])) {