]> git.kaiwu.me - quickjs.git/commitdiff
run-test2: don't increment the test number for strict mode - fixed print_error()...
authorFabrice Bellard <fabrice@bellard.org>
Sat, 26 Sep 2026 14:44:20 +0000 (16:44 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 26 Sep 2026 14:44:20 +0000 (16:44 +0200)
run-test262.c
test262_errors.txt

index 9d03964e4ed616241bc51281ae14a692939ea58e..c7d9c82827cf8842284abc8f0b03ae16b8ab22fc 100644 (file)
@@ -1363,17 +1363,31 @@ int longest_match(const char *str, const char *find, int pos, int *ppos, int lin
 
 static __attribute__((__format__(__printf__, 1, 2))) void print_error(const char *fmt, ...)
 {
-    char buf[1024];
     va_list ap;
-    va_start(ap, fmt);
-    vsnprintf(buf, sizeof(buf), fmt, ap);
-    va_end(ap);
     if (update_errors) {
+        char buf[256], *str;
+        int len;
+
+        va_start(ap, fmt);
+        len = vsnprintf(buf, sizeof(buf), fmt, ap);
+        va_end(ap);
+        if (len >= sizeof(buf)) {
+            str = malloc(len + 1);
+            va_start(ap, fmt);
+            vsnprintf(str, len + 1, fmt, ap);
+            va_end(ap);
+        } else {
+            str = buf;
+        }
         pthread_mutex_lock(&error_list_mutex);
-        namelist_add(&error_list, NULL, buf);
+        namelist_add(&error_list, NULL, str);
         pthread_mutex_unlock(&error_list_mutex);
+        if (str != buf)
+            free(str);
     } else {
-        fputs(buf, stdout);
+        va_start(ap, fmt);
+        vprintf(fmt, ap);
+        va_end(ap);
     }
 }
 
@@ -1776,15 +1790,6 @@ int run_test_buf(ThreadLocalStorage *tls,
     js_agent_free(ctx);
     JS_FreeContext(ctx);
     JS_FreeRuntime(rt);
-
-    atomic_inc(&test_count);
-    if (ret) {
-        atomic_inc(&test_failed);
-        if (outfile) {
-            /* do not output a failure number to minimize diff */
-            fprintf(outfile, "  FAILED\n");
-        }
-    }
     return ret;
 }
 
@@ -2011,12 +2016,25 @@ int run_test(ThreadLocalStorage *tls, const char *filename, int index)
                                error_type, eval_flags, is_negative, is_async,
                                can_block);
         }
-        if (use_strict) {
+        /* we avoid running the strict mode test if there was an error
+           in the nostrict case to have a single error report per
+           test */
+        if (use_strict && ret == 0) {
             ret |= run_test_buf(tls, filename, harness, ip, buf, buf_len,
                                 error_type, eval_flags | JS_EVAL_FLAG_STRICT,
                                 is_negative, is_async, can_block);
         }
         clocks = clock() - clocks;
+
+        atomic_inc(&test_count);
+        if (ret) {
+            atomic_inc(&test_failed);
+            if (outfile) {
+                /* do not output a failure number to minimize diff */
+                fprintf(outfile, "  FAILED\n");
+            }
+        }
+        
         if (outfile && index >= 0 && clocks >= CLOCKS_PER_SEC / 10) {
             /* output timings for tests that take more than 100 ms */
             fprintf(outfile, " time: %d ms\n", (int)(clocks * 1000LL / CLOCKS_PER_SEC));
@@ -2224,6 +2242,7 @@ void help(void)
            "-s             run tests in strict mode, skip @nostrict tests\n"
            "-E             only run tests from the error file\n"
            "-C             use compact progress indicator\n"
+           "-q             no progress indicator\n"
            "-t             show timings\n"
            "-u             update error file\n"
            "-v             verbose: output error messages\n"
@@ -2259,6 +2278,7 @@ int main(int argc, char **argv)
     BOOL is_module = FALSE;
     BOOL can_block = TRUE;
     BOOL count_skipped_features = FALSE;
+    int enable_progress = -1;
     clock_t clocks;
     
     init_thread_local_storage(tls);
@@ -2266,7 +2286,6 @@ int main(int argc, char **argv)
     pthread_mutex_init(&error_list_mutex, NULL);
 
 #if !defined(_WIN32)
-    compact = !isatty(STDERR_FILENO);
     /* Date tests assume California local time */
     setenv("TZ", "America/Los_Angeles", 1);
 #endif
@@ -2309,7 +2328,10 @@ int main(int argc, char **argv)
         } else if (str_equal(arg, "-v")) {
             verbose++;
         } else if (str_equal(arg, "-C")) {
+            enable_progress = 1;
             compact = 1;
+        } else if (str_equal(arg, "-q")) {
+            enable_progress = 0;
         } else if (str_equal(arg, "-c")) {
             load_config(get_opt_arg(arg, argv[optind++]), ignore);
         } else if (str_equal(arg, "-d")) {
@@ -2372,6 +2394,14 @@ int main(int argc, char **argv)
 
     update_exclude_dirs();
 
+    if (enable_progress < 0) {
+#if defined(_WIN32)
+        enable_progress = 1;
+#else
+        enable_progress = (isatty(STDERR_FILENO) != 0);
+#endif
+    }
+    
     clocks = clock();
 
     if (count_skipped_features) {
@@ -2428,8 +2458,10 @@ int main(int argc, char **argv)
 
         pthread_cond_init(&progress_cond, NULL);
         pthread_mutex_init(&progress_mutex, NULL);
-        pthread_create(&progress_thread, NULL, show_progress, NULL);
-
+        if (enable_progress) {
+            pthread_create(&progress_thread, NULL, show_progress, NULL);
+        }
+        
         threads = malloc(sizeof(threads[0]) * nthreads);
         for (i = 0; i < nthreads; i++) {
             RunTestDirThread *th = &threads[i];
@@ -2446,12 +2478,13 @@ int main(int argc, char **argv)
             pthread_join(threads[i].tid, NULL);
         free(threads);
 
-        pthread_mutex_lock(&progress_mutex);
-        progress_exit_request = TRUE;
-        pthread_cond_signal(&progress_cond);
-        pthread_mutex_unlock(&progress_mutex);
-        pthread_join(progress_thread, NULL);
-
+        if (enable_progress) {
+            pthread_mutex_lock(&progress_mutex);
+            progress_exit_request = TRUE;
+            pthread_cond_signal(&progress_cond);
+            pthread_mutex_unlock(&progress_mutex);
+            pthread_join(progress_thread, NULL);
+        }
         pthread_mutex_destroy(&progress_mutex);
         pthread_cond_destroy(&progress_cond);
 
@@ -2459,6 +2492,9 @@ int main(int argc, char **argv)
             fclose(outfile);
             outfile = NULL;
         }
+        /* useful to have the report at the end in case stdout and
+           stderr are redirected to a single file */
+        fflush(stdout); 
     } else {
         outfile = stdout;
         while (optind < argc) {
@@ -2551,5 +2587,9 @@ int main(int argc, char **argv)
     free(error_file);
 
     /* Signal that the error file is out of date. */
-    return new_errors || changed_errors || fixed_errors;
+    if (update_errors) {
+        return 0;
+    } else {
+        return new_errors || changed_errors || fixed_errors;
+    }
 }
index 6f59bcac9632261740c807280b50ffdbdf5f3fb5..340bef5afbcdbd95b33c13e5591ee81e1a164ade 100644 (file)
@@ -6,9 +6,7 @@ test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-
 test262/test/annexB/language/expressions/assignmenttargettype/callexpression.js:33: SyntaxError: invalid assignment left-hand side
 test262/test/annexB/language/expressions/assignmenttargettype/cover-callexpression-and-asyncarrowhead.js:20: SyntaxError: invalid assignment left-hand side
 test262/test/built-ins/Promise/try/avoids-wrap-for-subclass.js:10: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
-test262/test/built-ins/Promise/try/avoids-wrap-for-subclass.js:10: strict mode: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
 test262/test/built-ins/Promise/try/avoids-wrap.js:10: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
-test262/test/built-ins/Promise/try/avoids-wrap.js:10: strict mode: Test262Error: Expected SameValue(«[object Promise]», «[object Promise]») to be true
 test262/test/language/expressions/assignment/S11.13.1_A6_T1.js:23: Test262Error: #1: innerX === undefined. Actual: 1
 test262/test/language/expressions/assignment/S11.13.1_A6_T2.js:23: Test262Error: #1: innerX === 2. Actual: 1
 test262/test/language/expressions/compound-assignment/S11.13.2_A6.1_T1.js:24: Test262Error: #1: innerX === 2. Actual: 12
@@ -30,21 +28,15 @@ test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguou
 test262/test/language/module-code/namespace/internals/super-access-to-tdz-binding.js:32: Test262Error: Expected a ReferenceError but got a TypeError
 test262/test/staging/sm/Function/arguments-parameter-shadowing.js:14: Test262Error: Expected SameValue(«true», «false») to be true
 test262/test/staging/sm/Function/constructor-binding.js:11: Test262Error: Expected SameValue(«"function"», «"undefined"») to be true
-test262/test/staging/sm/Function/constructor-binding.js:11: strict mode: Test262Error: Expected SameValue(«"function"», «"undefined"») to be true
 test262/test/staging/sm/Function/function-bind.js:24: Test262Error: Conforms to NativeFunction Syntax: "function bound unbound() {\n    [native code]\n}"
 test262/test/staging/sm/Function/function-name-for.js:13: Test262Error: Expected SameValue(«""», «"forInHead"») to be true
 test262/test/staging/sm/Function/implicit-this-in-parameter-expression.js:12: Test262Error: Expected SameValue(«[object Object]», «undefined») to be true
 test262/test/staging/sm/Function/invalid-parameter-list.js:13: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
-test262/test/staging/sm/Function/invalid-parameter-list.js:13: strict mode: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
 test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:11: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
-test262/test/staging/sm/async-functions/async-contains-unicode-escape.js:11: strict mode: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
 test262/test/staging/sm/async-functions/await-in-arrow-parameters.js:10: Test262Error: AsyncFunction:(a = (b = await/r/g) => {}) => {} Expected a SyntaxError to be thrown but no exception was thrown at all
-test262/test/staging/sm/async-functions/await-in-arrow-parameters.js:10: strict mode: Test262Error: AsyncFunction:(a = (b = await/r/g) => {}) => {} Expected a SyntaxError to be thrown but no exception was thrown at all
 test262/test/staging/sm/class/boundFunctionSubclassing.js:9: Test262Error: Expected SameValue(«false», «true») to be true
-test262/test/staging/sm/class/boundFunctionSubclassing.js:9: strict mode: Test262Error: Expected SameValue(«false», «true») to be true
 test262/test/staging/sm/class/strictExecution.js:13: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
 test262/test/staging/sm/class/superPropOrdering.js:17: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
-test262/test/staging/sm/class/superPropOrdering.js:17: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
 test262/test/staging/sm/generators/syntax.js:50: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
 test262/test/staging/sm/lexical-environment/block-scoped-functions-annex-b-arguments.js:13: Test262Error: Expected SameValue(«"object"», «"function"») to be true
 test262/test/staging/sm/lexical-environment/block-scoped-functions-annex-b-eval.js:11: Test262Error: Expected SameValue(«"outer-gouter-geval-gtruefalseq"», «"outer-geval-gwith-gtruefalseq"») to be true
@@ -53,11 +45,7 @@ test262/test/staging/sm/lexical-environment/block-scoped-functions-annex-b-notap
 test262/test/staging/sm/lexical-environment/block-scoped-functions-deprecated-redecl.js:23: Test262Error: Expected SameValue(«3», «4») to be true
 test262/test/staging/sm/lexical-environment/var-in-catch-body-annex-b-eval.js:16: Test262Error: Expected SameValue(«"g"», «"global-x"») to be true
 test262/test/staging/sm/object/defineProperties-order.js:11: Test262Error: Expected SameValue(«"ownKeys,getOwnPropertyDescriptor,getOwnPropertyDescriptor,get,get"», «"ownKeys,getOwnPropertyDescriptor,get,getOwnPropertyDescriptor,get"») to be true
-test262/test/staging/sm/object/defineProperties-order.js:11: strict mode: Test262Error: Expected SameValue(«"ownKeys,getOwnPropertyDescriptor,getOwnPropertyDescriptor,get,get"», «"ownKeys,getOwnPropertyDescriptor,get,getOwnPropertyDescriptor,get"») to be true
 test262/test/staging/sm/regress/regress-602621.js:13: Test262Error: function sub-statement must override arguments Expected SameValue(«"function"», «"object"») to be true
 test262/test/staging/sm/regress/regress-1383630.js:28: Test262Error: proxy must report the same value for the non-writable, non-configurable property Expected a TypeError to be thrown but no exception was thrown at all
-test262/test/staging/sm/regress/regress-1383630.js:28: strict mode: Test262Error: proxy must report the same value for the non-writable, non-configurable property Expected a TypeError to be thrown but no exception was thrown at all
 test262/test/staging/sm/statements/arrow-function-in-for-statement-head.js:13: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
-test262/test/staging/sm/statements/arrow-function-in-for-statement-head.js:13: strict mode: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all
 test262/test/staging/sm/statements/try-completion.js:11: Test262Error: Expected SameValue(«"try"», «undefined») to be true
-test262/test/staging/sm/statements/try-completion.js:11: strict mode: Test262Error: Expected SameValue(«"try"», «undefined») to be true