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

Formatting improvements #246

Merged
merged 21 commits into from
Jul 2, 2020
Merged

Formatting improvements #246

merged 21 commits into from
Jul 2, 2020

Conversation

craigfe
Copy link
Member

@craigfe craigfe commented May 25, 2020

Fixes #252 and fixes #240.

No API changes, but lots of diffs to pretty-printing logic.

image

Shortlist of changes:

  • output is generally more colorful (e.g. passing around unit Fmt.t values rather than strings);
  • improve diff shown on Alcotest.check failure to be better aligned & spaced;
  • highlight the test case whose error is printed with >;
  • keep a more consistent distinction between ERROR and FAIL states;
  • show shorter directory names to the user (e.g. use the symlinks rather than UUIDs, collapse home directory to ~).

@craigfe craigfe mentioned this pull request May 25, 2020
7 tasks
@samoht
Copy link
Member

samoht commented May 25, 2020

What's the difference between FAIL and ERROR?

@craigfe
Copy link
Member Author

craigfe commented May 25, 2020

  • FAIL: test failures caused by Alcotest.fail and Alcotest.check_raises;
  • ERROR: test failures caused by Alcotest.check or exceptions thrown in test.

It's fairly arbitrary, but I'm preserving the existing distinction. Perhaps we want to reconsider it at this stage: for instance, it makes sense for me for Alcotest.check_raises to be considered an ERROR, or to drop the distinction entirely.

@samoht
Copy link
Member

samoht commented Jun 1, 2020

Yes we should drop the distinction. I can't remember why I thought it was a good idea initially :p

craigfe added a commit to craigfe/alcotest that referenced this pull request Jun 1, 2020
... instead of the previous state of distinguishing between `FAIL' and
`ERROR' states. See the discussion in
mirage#246 (comment).
@craigfe craigfe force-pushed the layout-improvements branch 6 times, most recently from 4e3eaf2 to 2b9e01c Compare June 1, 2020 18:40
@craigfe
Copy link
Member Author

craigfe commented Jun 1, 2020

Yes we should drop the distinction.

@samoht: Now done.

New changes:

Also trying to sneak in some general refactoring in the internal handling of data. Mostly pushing definitions and logic into a new model.ml file that keeps some better abstraction on e.g. whether strings have been escaped, which form should be pretty-printed etc.

Happy to pull these changes into a separate PR if requested.

craigfe added a commit to craigfe/alcotest that referenced this pull request Jun 2, 2020
... instead of the previous state of distinguishing between `FAIL' and
`ERROR' states. See the discussion in
mirage#246 (comment).
@craigfe
Copy link
Member Author

craigfe commented Jun 2, 2020

Rebased. This can now be considered for merge.

Testing `check_basic'.
This run has ID `<uuid>'.

... different basic 0 bool.ASSERT bool
Copy link
Member

Choose a reason for hiding this comment

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

why is there an ASSERT boolin the middle of that line?

Copy link
Member Author

Choose a reason for hiding this comment

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

When using --verbose, these asserts are interleaved with the standard output.

──────────────────────────────────────────────────────────────────────────────


┌──────────────────────────────────────────────────────────────────────────────┐
Copy link
Member

Choose a reason for hiding this comment

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

Is the new default behaviour to show all the failures? I don't think that's a good idea, the previous default is just to show the first one unless ALCOTEST_SHOW_ERRORS is set (if I remember correctly).

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this isn't default. There's a corresponding change to the Alcotest.run to pass ~verbose:true (https://github.com/mirage/alcotest/pull/246/files#diff-fb43ad350d97f3cf0e25d21ec53a881dR7).

I felt that this is a better test if all of the errors are printed.

craigfe added 12 commits June 5, 2020 15:02
The 'latest' symlink is less useful in projects with many different test
binaries (such as this one), since each suite runner overwrites the
symlink from the previous one.
This test causes plenty of trouble in CI, and seems to be not very
portable. The important test is that it's possible to _override_ the
default, which has been kept.
... instead of the previous state of distinguishing between `FAIL' and
`ERROR' states. See the discussion in
mirage#246 (comment).
@craigfe
Copy link
Member Author

craigfe commented Jun 5, 2020

Rebased, and switched out the last change for one that doesn't use brands.

... by switching to an escaped form when using the suite name as a
symlink. The pretty-printed form is unaffected.
@craigfe
Copy link
Member Author

craigfe commented Jun 16, 2020

Pushed a small addition to the UTF-8 improvement that also handles printing of UTF-8 characters in suite names (previously we were just dealing with test names). This now fixes #240.

Now is a good time for a second review 🙂

@samoht
Copy link
Member

samoht commented Jul 2, 2020

This looks very good, thanks!

@samoht samoht merged commit 1c51b8f into mirage:master Jul 2, 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)
@craigfe craigfe deleted the layout-improvements branch August 18, 2020 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants