From 4c7c6dba6048ab4fef68305f1454606dc0adaab3 Mon Sep 17 00:00:00 2001 From: Takahiro Ueda Date: Tue, 13 Oct 2026 20:27:56 +0900 Subject: [PATCH] test(check.rb): detect internal errors Add an internal_error? helper method to detect internal errors generated by "!>" markers. Update succeeded? to return false if any internal errors are detected. --- check/README.md | 6 ++++-- check/check.rb | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/check/README.md b/check/README.md index 268d72e93..acb9fa5f3 100644 --- a/check/README.md +++ b/check/README.md @@ -245,8 +245,8 @@ The following methods are available in Ruby test programs. `true` if the FORM job issued the expected warning, otherwise `false`. The following methods are similar to `warning?`, -but they check for preprocessor errors, compile-time errors, -and run-time errors, respectively: +but they check for preprocessor errors, compile-time errors, run-time errors, +and internal errors (which should never happen), respectively: - `preprocess_error? → bool` `preprocess_error?(expected_message : string) → bool` @@ -254,6 +254,8 @@ and run-time errors, respectively: `compile_error?(expected_message : string) → bool` - `runtime_error? → bool` `runtime_error?(expected_message : string) → bool` +- `internal_error? → bool` + `internal_error?(expected_message : string) → bool` #### Standard streams diff --git a/check/check.rb b/check/check.rb index 835e5407d..0283ba2cc 100755 --- a/check/check.rb +++ b/check/check.rb @@ -799,10 +799,19 @@ def runtime_error?(expected_message = nil) end end + # true if the FORM job reported an internal error, which should never happen. + def internal_error?(expected_message = nil) + if expected_message.nil? + @stdout =~ / ~~> Internal error/ + else + @cleaned_stdout =~ / ~~> Internal error.*#{Regexp.escape(expected_message)}/ + end + end + # true if the FORM job completed without any warnings/errors and # the exit code was 0. def succeeded? - if finished? && !warning? && !preprocess_error? && !compile_error? && !runtime_error? && return_value == 0 + if finished? && !warning? && !preprocess_error? && !compile_error? && !runtime_error? && !internal_error? && return_value == 0 if FormTest.cfg.valgrind.nil? if @stderr.empty? return true