Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do-check-condition should catch <condition>, not <serious-condition> #184

Open
cgay opened this issue Feb 3, 2025 · 0 comments
Open

do-check-condition should catch <condition>, not <serious-condition> #184

cgay opened this issue Feb 3, 2025 · 0 comments

Comments

@cgay
Copy link
Member

cgay commented Feb 3, 2025

The inner block, where thunk() is called, should catch <condition>, as the comment suggests. Consider using assert-signals on compiler warning conditions, which are not <serious-condition>s. If the compiler signals a disjoint condition class we won't catch and record it correctly.

Potentially overlaps with #183

define function do-check-condition
    (description-thunk :: <function>, get-arguments :: <function>, caller :: <string>,
     #key terminate? :: <boolean>)
 => ()
  let phase = format-to-string("evaluating %s description", caller);
  let description :: false-or(<string>) = #f;
  block ()
    description := eval-check-description(description-thunk);
    phase := format-to-string("evaluating %s expression", caller);
    let (condition-class, thunk :: <function>, expr :: <string>) = get-arguments();
    phase := format-to-string("checking if %= signals a condition of class %s",
                              expr, condition-class);
    block ()
      thunk();
      record-check(description, $failed, "no condition signaled");
      terminate? & signal(make(<assertion-failure>));
    exception (ex :: condition-class)
      record-check(description, $passed, #f);
      // Not really sure if this should catch something broader, like
      // <condition>, but leaving it this way for compat with old code.
    exception (ex :: <serious-condition>)
      record-check(description, $failed,
                   format-to-string("condition of class %s signaled; "
                                      "expected a condition of class %s. "
                                      "The error was: %s",
                                    ex.object-class, condition-class, ex));
      terminate? & signal(make(<assertion-failure>));
    end;
  exception (err :: <serious-condition>, test: method (cond) ~debug?() end)
    record-check(description | $invalid-description,
                 $crashed,
                 format-to-string("Error %s: %s", phase, err));
    terminate? & signal(make(<assertion-failure>));
  end block
end function do-check-condition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant