diff --git a/test/broken_lua.lp b/test/broken_lua.lp index 32f57aff..bf8a5fef 100644 --- a/test/broken_lua.lp +++ b/test/broken_lua.lp @@ -1,4 +1,4 @@ \ No newline at end of file +mg.write("Hello, world 1!\n") +mg.include("broken_lua_2.lp", "r") +?> diff --git a/test/broken_lua_2.lp b/test/broken_lua_2.lp new file mode 100644 index 00000000..e0ada85c --- /dev/null +++ b/test/broken_lua_2.lp @@ -0,0 +1,4 @@ + diff --git a/test/run.sh b/test/run.sh index 3a2ee4cf..e5d9331e 100755 --- a/test/run.sh +++ b/test/run.sh @@ -64,6 +64,7 @@ cp test/versions /etc/pihole/versions # Prepare Lua test script cp test/broken_lua.lp /var/www/html/broken_lua.lp +cp test/broken_lua_2.lp /var/www/html/broken_lua_2.lp # Prepare local powerDNS resolver bash test/pdns/setup.sh diff --git a/test/test_suite.bats b/test/test_suite.bats index 59b98902..b61733b9 100644 --- a/test/test_suite.bats +++ b/test/test_suite.bats @@ -1689,12 +1689,17 @@ # Run a page with a syntax error run bash -c 'curl -s 127.0.0.1/broken_lua' printf "%s\n" "${lines[@]}" - [[ ${lines[0]} == 'Hello, world!' ]] - [[ ${lines[1]} == '[string "/var/www/html/broken_lua.lp"]:4: Cannot include [/var/www/html/does_not_exist.lp]: not found' ]] - [[ ${lines[2]} == '' ]] + [[ ${lines[0]} == 'Hello, world 1!' ]] + [[ ${lines[1]} == 'Hello, world 2!' ]] + [[ ${lines[2]} == '[string "/var/www/html/broken_lua_2.lp"]:4: Cannot include [/var/www/html/does_not_exist.lp]: not found' ]] + [[ ${lines[3]} == 'stack traceback:' ]] + [[ ${lines[4]} == " [C]: in field 'include'" ]] + [[ ${lines[5]} == ' [string "/var/www/html/broken_lua.lp"]:4: in main chunk' ]] + [[ ${lines[6]} == 'aborting' ]] + [[ ${lines[7]} == '' ]] # Check if the error is logged (-F = fixed string (no regex), -q = quiet) - run grep -qF 'LSP Kepler: call failed: runtime error: [string "/var/www/html/broken_lua.lp"]:4: Cannot include [/var/www/html/does_not_exist.lp]: not found' /var/log/pihole/webserver.log + run grep -qF 'LSP Kepler: call failed: runtime error: [string "/var/www/html/broken_lua_2.lp"]:4: Cannot include [/var/www/html/does_not_exist.lp]: not found' /var/log/pihole/webserver.log [[ $status == 0 ]] }