racket / rackunit

Other
18 stars 32 forks source link

Fix incorrect usage of optional message in rackunit-test #158

Closed sorawee closed 2 years ago

sorawee commented 2 years ago

The tests either meant to use check = without an epsilon, or check-= with an epsilon. Currently, it uses check = with an epsilon, so the epsilon becomes a message. This PR fixes the tests.

Furthermore, there should be a guard to check that the optional message argument is indeed either #f or string?. This PR also does that.

samth commented 2 years ago

As @bogdanp noticed, this breaks one web-server test because the optional message argument was something else. We should probably just support that and convert to a string.

sorawee commented 2 years ago

The web-server test is objectively incorrect. It was wrongly assumed that the last argument is a regex pattern to be matched against the exception (so the fix is not just converting the regex to string, but also needing to restructure the entire test). So are the tests being fixed in this PR. It was wrongly assumed that the last argument is the epsilon (so either the epsilon must be dropped, or it must be refactored to use the epsilon somehow)

So while we can perform the conversion, that would silently hide bugs.

This is not just an undefined behavior that is undesirable. The documentation has always been clear that it's supposed to be a string. So I don't think that we should relax it.

mfelleisen commented 2 years ago

I had to fix a test in realm because of the stricter enforcement, and I think it is usually a problem with the test. This backwards incompatibility seems okay.

samth commented 2 years ago

On the one hand, I probably agree with @sorawee's argument in the abstract. On the other hand, these packages now have failing tests that didn't before:

Test Failures

sorawee commented 2 years ago

Oh no. Thanks for tracking these issues.

mfelleisen commented 2 years ago

On Jun 28, 2022, at 2:01 AM, sorawee @.***> wrote:

As far as I can tell, it intentionally uses the object as a a message

Ask the owners to use (~a (object-name o)) or perhaps advertise the idea, because it shows up in two repos. (I have done this too.)

sorawee commented 2 years ago

Thanks! I submitted PRs to address all of these issues except unlike-assets-test.

The issue with unlike-assets-test is that the version on the package server is a git commit (which in fact doesn't even exist...), so it is not possible to "fix" anything. As far as I can see, the latest commit of unlike-assets switches to use Denxi, so unlike-assets-test no longer exists, and that particular test was also removed at some point.

CC: @zyrolasting

zyrolasting commented 2 years ago

@sorawee Thanks for pinging me on this. Yes, that's the history, since I'm slowly (and painfully) migrating my code. I'm a little tight on time, but I will update the package source to something less vulnerable to my movements.