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

Normalize test names to support unicode #249

Merged
merged 5 commits into from
May 26, 2020

Conversation

gs0510
Copy link
Contributor

@gs0510 gs0510 commented May 25, 2020

Fix #171, normalize all names with the unicode representation of characters
other than alphabets, numbers, '-', '_' and ' '. If the character is malformed
then u_rep, the replacement character ( U+FFFD ) is added instead.

Copy link
Member

@craigfe craigfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to specify uutf as a dependency by adding it to the Alcotest (package) stanza (in dune-project) and running dune build @install.

This uses the escaped form of the name in the console output, which I believe is not necessary? e.g. in the test case, we could be printing the 🔥 emoji in the output. Regardless, this PR is still an improvement, and better CLI output could be a follow-up.

src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
src/alcotest-engine/core.ml Outdated Show resolved Hide resolved
@gs0510
Copy link
Contributor Author

gs0510 commented May 26, 2020

This uses the escaped form of the name in the console output, which I believe is not necessary? e.g. in the test case, we could be printing the fire emoji in the output. Regardless, this PR is still an improvement, and better CLI output could be a follow-up.

Oh nice! Yes seeing the actual test name would be a lot better than seeing the normalized name!
I'm trying to figure out where does the printing of the test names happen, is it here?

@craigfe
Copy link
Member

craigfe commented May 26, 2020

Indeed, most of the printing is done in https://github.com/mirage/alcotest/blob/master/src/alcotest-engine/pp.ml. However, there's another open PR with some fairly big diffs to this logic (#246), so it may not be worth bothering with right now. I hope that once that PR is in, this code will be easier to modify.

@craigfe
Copy link
Member

craigfe commented May 26, 2020

LGTM. Would you add a CHANGES entry? Then we can merge.

gs0510 and others added 5 commits May 26, 2020 16:25
Fix mirage#171, normalize all names with the unicode representation of characters
other than alphabets, numbers, '-', '_' and ' '. If the character is malformed
then u_rep, the replacement character ( U+FFFD ) is added instead.
Uutf has a String module with fold function
which simplifies the normalizing function a lot.
Update some names, and some cleanup.
The registering function can now be simplified since all inputs
are valid inputs and are normalized! 🎉
@craigfe
Copy link
Member

craigfe commented May 26, 2020

Rebased. Will merge when the CI goes green.

@craigfe
Copy link
Member

craigfe commented May 26, 2020

Thanks for the contribution 😊

@craigfe craigfe merged commit 66e1490 into mirage:master May 26, 2020
@craigfe craigfe mentioned this pull request Jun 1, 2020
craigfe added a commit to craigfe/opam-repository that referenced this pull request Jul 13, 2020
…age (1.2.0)

CHANGES:

- Add an `alcotest-mirage` package, allowing the construction of MirageOS
  unikernels that run Alcotest test suites. (mirage/alcotest#238, @hannesm @linse)

- Add `Alcotest.check'`, a variant of `Alcotest.check` with labeled arguments.
  (mirage/alcotest#239, @hartmut27)

- Add a testable for the `bytes` type. (mirage/alcotest#253, @mefyl)

- Many assorted improvements to Alcotest output formatting. (mirage/alcotest#246, @craigfe)

- Default to `--color=always` when running inside Dune (mirage/alcotest#242, @craigfe). The
  value can be overridden by setting the `ALCOTEST_COLOR` variable in a `dune`
  file, for example:

```dune
(env
 (_
  (env-vars
   (ALCOTEST_COLOR auto))))
```

- Support all UTF-8 characters in test names and suite names, by normalising
  them for file-system interactions. (mirage/alcotest#249, @gs0510; mirage/alcotest#246, @craigfe)

- Fix various crashes when using non-filesystem-safe characters in test suite
  names (these break Alcotest when attempting to generate a corresponding log
  file). (mirage/alcotest#241, @mefyl; mirage/alcotest#246 @craigfe)
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

Successfully merging this pull request may close these issues.

Support unicode test names
2 participants