Skip to content

Formatting improvements - #246

Merged
samoht merged 21 commits into
mirage:masterfrom
craigfe:layout-improvements
Jul 2, 2020
Merged

samoht merged 21 commits into
mirage:masterfrom
craigfe:layout-improvements

Conversation

@craigfe

@craigfe craigfe commented May 25, 2020 •

Copy link
Copy Markdown
Member

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

samoht commented May 25, 2020

Copy link
Copy Markdown
Member

What's the difference between FAIL and ERROR?

@craigfe

craigfe commented May 25, 2020 •

Copy link
Copy Markdown
Member Author
  • 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

samoht commented Jun 1, 2020

Copy link
Copy Markdown
Member

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

@craigfe
craigfe force-pushed the layout-improvements branch from 02080c2 to 5c32f40 Compare June 1, 2020 11:15
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

craigfe commented Jun 1, 2020

Copy link
Copy Markdown
Member Author

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
craigfe force-pushed the layout-improvements branch from 2b9e01c to 41b72fa Compare June 2, 2020 10:03
@craigfe

craigfe commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

Rebased. This can now be considered for merge.

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

... different basic 0 bool.ASSERT bool

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/alcotest-engine/alcotest_engine.mli Resolved
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
craigfe force-pushed the layout-improvements branch from 41b72fa to f321ced Compare June 5, 2020 13:36
@craigfe

craigfe commented Jun 5, 2020

Copy link
Copy Markdown
Member Author

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

@craigfe
craigfe force-pushed the layout-improvements branch from f321ced to e6d77bc Compare June 5, 2020 14:17
... by switching to an escaped form when using the suite name as a
symlink. The pretty-printed form is unaffected.
@craigfe

craigfe commented Jun 16, 2020

Copy link
Copy Markdown
Member Author

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

samoht commented Jul 2, 2020 •

Copy link
Copy Markdown
Member

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

Development

Successfully merging this pull request may close these issues.

Expected and actual output do not stand enough in the output Test suite fails if there is a path separator in user-supplied strings.

2 participants