MCPcopy Index your code
hub / github.com/nodejs/node / has_unexpected_errors

Function has_unexpected_errors

deps/v8/tools/gcmole/gcmole.py:525–580  ·  view source on GitHub ↗

Returns True if error state isn't as expected, False otherwise. In test-run mode, we expect certain errors and return False if expectations are met.

(options, errors_found, file_io)

Source from the content-addressed store, hash-verified

523 clean_block, output)
524
525def has_unexpected_errors(options, errors_found, file_io):
526 """Returns True if error state isn't as expected, False otherwise.
527
528 In test-run mode, we expect certain errors and return False if expectations
529 are met.
530 """
531 if not options.test_run:
532 return errors_found
533
534 log("Test Run")
535 output = clean_test_output(file_io.getvalue())
536 if not errors_found:
537 log("Test file should produce errors, but none were found. Output:")
538 print(output)
539 return True
540
541 new_file = options.out_dir / "test-expectations-gen.txt"
542 with open(new_file, "w") as f:
543 f.write(output)
544 log("Wrote test-results: {}", new_file)
545
546 expected_file = options.v8_root_dir / "tools/gcmole/test-expectations.txt"
547 with open(expected_file) as exp_file:
548 expectations = exp_file.read()
549
550 if output != expectations:
551 diff_file = options.out_dir / "test_output.diff"
552 print("#" * 79)
553 log("Output mismatch from running tests.")
554 log("Please run gcmole manually with --test-run --verbose.")
555 log(f"Expected: {expected_file}")
556 log(f"New: {new_file}")
557 log(f"*Diff:* {diff_file}")
558 print("#" * 79)
559 for line in difflib.unified_diff(
560 expectations.splitlines(),
561 output.splitlines(),
562 fromfile=str(new_file),
563 tofile=str(diff_file),
564 lineterm="",
565 ):
566 print(line)
567
568 print("#" * 79)
569 log("Full output")
570 log(f"Expected: {expected_file}")
571 log(f"Diff: {diff_file}")
572 log(f"*New*: {new_file}")
573 print("#" * 79)
574 print(output)
575 print("#" * 79)
576
577 return True
578
579 log("Tests ran successfully")
580 return False
581
582

Callers 1

check_filesFunction · 0.85

Calls 8

clean_test_outputFunction · 0.85
strFunction · 0.85
logFunction · 0.70
printFunction · 0.50
openFunction · 0.50
writeMethod · 0.45
readMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…