Shinmera / parachute

An extensible and cross-compatible testing framework.
https://shinmera.github.io/parachute
zlib License
94 stars 9 forks source link

Issues with X and ? on Windows because of CHARSET:CP437 #40

Closed schrum2 closed 1 year ago

schrum2 commented 2 years ago

I've just started playing with parachute in Github codespaces (which is based on Ubuntu), and it seemed to run fine. However, now I'm trying to run the same code on my Windows machine, and am getting this error when using GNU CLisp:

         PRINC: Character #\uFF1F cannot be represented in the character set CHARSET:CP437

  0.003
*** - PRINC: Character #\u2718 cannot be represented in the character set CHARSET:CP437

These are the ? and ✘ characters. This seems like a stupid limitation of Windows terminals (and it affected both PowerShell and the Git bash), but is also a silly reason for the code to crash. If only I could map these characters to regular ? and X. I think the checkmark also has a problem. In any case, I've figured out this work-around:

(setf custom:*terminal-encoding*
      (ext:make-encoding :charset charset:utf-8
                         :line-terminator :dos))

However, this replaces the characters with these symbols: ? and ✔

Here is what is looks like in context with one of your example tests:

Break 1 PARACHUTE[5]> (test `numbers)
        ? PARACHUTE::NUMBERS
  0.002 Γ£ö   (of-type integer 5)
  0.000 Γ£ö   (true (numberp 2/3))
  0.000 Γ£ö   (false (numberp :keyword))
  0.001 Γ£ö   (is-values (values 0 "1") (= 0) (equal "1"))
  0.023 Γ£ö PARACHUTE::NUMBERS

;; Summary:
Passed:     4
Failed:     0
Skipped:    0
#<PLAIN 5, PASSED results>

It seems like simply not using these characters would solve the issue, but in the meantime, any idea on a better solution for how to display this nicely?

Shinmera commented 2 years ago

Have you tried changing the code page of the terminals?

Shinmera commented 2 years ago

To be clear I don't know what else to do about this because there's no way for me to determine under which output terminal settings (if any at all) the program is running. Such things are not part of the standard.

schrum2 commented 2 years ago

So, I finally got a chance to try this on a completely different machine at my university computer lab, and I got the exact same error. I don't think I or the university computer are using any unusual settings. I think this is just a problem with getting parachute to work on Windows ... Windows 10 specifically, though the problem might affect other versions. I guess it seems weird that I might be the only person experiencing problems under Windows, though I do honestly wonder how many other Lisp programmers are doing unit testing on Windows. Then again, Lisp has so many different testing frameworks out there, perhaps a lot of people just switch to a different unit testing framework when they encounter this error.

"Have you tried changing the code page of the terminals?" I'm not sure how to do this, but it sounds like it would involve changing some sort of configuration on my system, and (in light of the test above) seemingly every system that I run this code on.

I suppose that using GNU CLisp specifically on Windows could also be the source of the problem, and maybe you can't make sure parachute works with all possible combinations of OS and Lisp version. However, it seems like a simple fix would just be to use different characters, at least in the case where an error like this is detected.

In any case, my use of charset:utf-8 is a sufficient work-around for my purposes, despite the fact that it results in funky character output.

Shinmera commented 1 year ago

You can either remove the ASDF-UNICODE feature prior to compiling Parachute, or redefine the new STATUS-CHARACTER function to suit your needs.