[njs] Tests: added support for proper negative test262 tests.

Dmitry Volyntsev xeioex at nginx.com
Thu Jan 27 13:03:27 UTC 2022


details:   https://hg.nginx.org/njs/rev/b4998a4f82dc
branches:  
changeset: 1821:b4998a4f82dc
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Jan 26 17:24:58 2022 +0000
description:
Tests: added support for proper negative test262 tests.

diffstat:

 test/options |   5 +++++
 test/prepare |   3 +++
 test/test262 |  21 +++++++++++++--------
 3 files changed, 21 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r 403f7fe07fe8 -r b4998a4f82dc test/options
--- a/test/options	Wed Jan 26 02:44:18 2022 +0100
+++ b/test/options	Wed Jan 26 17:24:58 2022 +0000
@@ -59,3 +59,8 @@ do
 done
 
 NJS_TEST_PATHS=${@:-test}
+
+NJS_TEST_EXIT_CODE=1
+if echo $NJS_TEST_BINARY | grep -q njs; then
+    NJS_TEST_EXIT_CODE=23
+fi
diff -r 403f7fe07fe8 -r b4998a4f82dc test/prepare
--- a/test/prepare	Wed Jan 26 02:44:18 2022 +0100
+++ b/test/prepare	Wed Jan 26 17:24:58 2022 +0000
@@ -7,6 +7,9 @@ njs_includes=`grep 'includes: \[[^]]*]' 
              | sed -e 's/includes: \[//' | sed -e 's/,/ /g' | sed -e 's/\]//'`
 njs_includes="assert.js sta.js $njs_includes"
 
+njs_paths=`grep 'paths: \[[^]]*]' $njs_test \
+             | sed -e 's/paths: \[//' | sed -e 's/ *, */:/g' | sed -e 's/\]//'`
+
 njs_flags=`grep 'flags: \[[^]]*]' $njs_test \
              | sed -e 's/flags: \[//' | sed -e 's/,/ /g' | sed -e 's/\]//'`
 
diff -r 403f7fe07fe8 -r b4998a4f82dc test/test262
--- a/test/test262	Wed Jan 26 02:44:18 2022 +0100
+++ b/test/test262	Wed Jan 26 17:24:58 2022 +0000
@@ -19,18 +19,18 @@ for njs_test in $NJS_TESTS; do
 running $njs_test $njs_log
 END
 
-    if /bin/sh -c "(NJS_TEST_DIR=$NJS_TEST_DIR $NJS_TEST_BINARY $NJS_TEST_DIR/$njs_test)" > $njs_log 2>&1; then
-        njs_success=yes
-    else
-        njs_success=no
-    fi
+    status=0
+
+    NJS_PATH=$njs_paths \
+    NJS_EXIT_CODE=$NJS_TEST_EXIT_CODE \
+    $NJS_TEST_BINARY $NJS_TEST_DIR/$njs_test > $njs_log 2>&1 || status=$?
 
     cat $njs_log >> $NJS_TEST_LOG
     njs_out=`cat $njs_log`
 
-    if [ $njs_success = yes ]; then
+    if [ "$status" -eq 0 ]; then
         if [ -n "$njs_negative" ]; then
-            failed $njs_test
+            failed $njs_test $njs_log
 
         elif [ $njs_async = yes ]; then
             if [ "$njs_out" != 'Test262:AsyncTestComplete' ]; then
@@ -51,7 +51,12 @@ END
 
     else
         if [ -n "$njs_negative" ]; then
-            passed $njs_test
+            if [ "$status" = "$NJS_TEST_EXIT_CODE" ]; then
+                passed $njs_test
+            else
+                echo "negative test exited with unexpected exit code:$status"
+                failed $njs_test $njs_log
+            fi
 
         else
             failed $njs_test $njs_log



More information about the nginx-devel mailing list