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

Support libtest's format=json unstable feature (#194, #203, #218) #220

Merged
merged 30 commits into from
Jul 20, 2022

Conversation

ilslv
Copy link
Member

@ilslv ilslv commented Jul 8, 2022

Resolves #194, #203, #218

Synopsis

By default CLion (and other JB IDEs) pass -- --format=json -Z unstable-options --show-output set of flags, which enables libtest (default rust test harness) JSON formatting. Currently this fails the CLI, because those flags are unknown.

Solution

Support JSON formatting.

Default output:
Screenshot 2022-07-08 at 15 22 09

With feature cargo-json and -- --format=json flag:
Screenshot 2022-07-08 at 15 20 18

As libtest's JSON output first line is:

{"type":"suite","event":"started","test_count":41}

We should somehow know number of test cases. Because of the event streaming nature of this library, to get number of test cases a new event has been added: event::Cucumber::ParsingFinished, which is emitted by runner::Basic right after all Features are parsed. There are no guarantees on when this event will be emitted, but it should happen exactly once.

Checklist

  • Created PR:
    • In draft mode
    • Name contains Draft: prefix
    • Name contains issue reference
    • Has assignee
  • Documentation is updated (if required)
  • Tests are updated (if required)
  • Changes conform code style
  • CHANGELOG entry is added (if required)
  • FCM (final commit message) is posted
    • and approved
  • Review is completed and changes are approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • Draft: prefix is removed
    • All temporary labels are removed

@ilslv ilslv added the enhancement Improvement of existing features or bugfix label Jul 8, 2022
@ilslv ilslv added this to the 0.14.0 milestone Jul 8, 2022
@ilslv ilslv self-assigned this Jul 8, 2022
# Conflicts:
#	CHANGELOG.md
#	README.md
#	book/src/introduction.md
#	book/src/output/json.md
#	book/src/output/junit.md
#	book/src/output/multiple.md
#	book/src/quickstart.md
#	book/src/writing/hooks.md
#	codegen/CHANGELOG.md
#	codegen/src/lib.rs
#	codegen/src/world.rs
#	src/codegen.rs
#	src/cucumber.rs
#	src/lib.rs
#	src/writer/summarize.rs
#	tests/after_hook.rs
#	tests/cli.rs
#	tests/json.rs
#	tests/junit.rs
#	tests/output.rs
#	tests/wait.rs
@ilslv
Copy link
Member Author

ilslv commented Jul 11, 2022

FCM

Support Rust `libtest`'s `--format=json` unstable feature to integrate with IntelliJ Rust pugin (#220, #194, #203, #218)

- add `libtest` Cargo feature
- impl `writer::Libtest`
- describe IntelliJ Rust integration in Book

Additionally:
- rework `writer::Failure`/`writer::discard::Failure` as `writer::Stats`/`writer::discard::Stats`
- add `writer::Or` to alternate between 2 `Writer`s basing on predicate
- add `FeatureExt::count_steps()` method

@ilslv ilslv marked this pull request as ready for review July 11, 2022 12:33
@ilslv ilslv changed the title Draft: Support libtest's format=json unstable feature (#194, #203, #218) Support libtest's format=json unstable feature (#194, #203, #218) Jul 11, 2022
@ilslv ilslv added the semver::breaking Represents breaking changes label Jul 11, 2022
@ilslv ilslv requested a review from tyranron July 11, 2022 13:57
@ilslv ilslv removed the request for review from tyranron July 11, 2022 17:48
@ilslv ilslv requested a review from tyranron July 12, 2022 05:32
Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

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

@ilslv nice job overall 👍

Though, some stuff is not quite clear, and some needs polishing.

.github/workflows/ci.yml Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
tests/libtest.rs Show resolved Hide resolved
src/writer/fail_on_skipped.rs Show resolved Hide resolved
src/writer/fail_on_skipped.rs Show resolved Hide resolved
codegen/tests/two_worlds.rs Outdated Show resolved Hide resolved
src/writer/libtest.rs Show resolved Hide resolved
tests/libtest/correct.stdout Outdated Show resolved Hide resolved
src/writer/libtest.rs Outdated Show resolved Hide resolved
@ilslv ilslv requested a review from tyranron July 15, 2022 13:33
@ilslv
Copy link
Member Author

ilslv commented Jul 15, 2022

nightly ICE has already been reported.

src/writer/mod.rs Outdated Show resolved Hide resolved
src/writer/libtest.rs Show resolved Hide resolved
@ilslv ilslv requested a review from tyranron July 19, 2022 08:29
Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

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

@ilslv thanks!

@tyranron tyranron merged commit 5b600d8 into main Jul 20, 2022
@tyranron tyranron deleted the libtest-format-json branch July 20, 2022 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix semver::breaking Represents breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Json CLI Argument
2 participants