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

Fix typespec_derive compilation tests #1899

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

analogrelay
Copy link
Member

Fixes #1896

There were two problems here, and I've fixed both:

  1. The compilation tests have the wrong path in their path reference. I moved the compilation tests to a different directory and forgot to update this. However, because of the next issue, the tests didn't fail

  2. The tests don't fail if a file produces no errors. We collect all errors, group by file, and then look for an .expected.json to compare/generate a baseline. However, if a file produces no errors but has an .expected.json file, we don't fail.

Fixing 2 caused 1 to immediately start failing the test.

To fix 2, I went with a fairly simple approach for now of scanning for .expected.json files in the test project. Then we compare that list against the list of files the compiler found errors in (after sorting both consistently). This does mean that when adding a new file, you'll have to add an empty .expected.json file for it, but that should be OK given how infrequently we update these files.

let reader = BufReader::new(compilation.stdout.take().unwrap());
let messages = Message::parse_stream(reader);
.expect("cargo to start running")
.wait_with_output()
Copy link
Member

Choose a reason for hiding this comment

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

This didn't deadlock for you? When I tried it in #1895 it deadlocked and I had to do something different.

// Probably save to assume cargo is on the path, but if that's not the case, tests will start failing and we'll figure it out.
let mut compilation = std::process::Command::new("cargo")
let output = std::process::Command::new("cargo")
Copy link
Member

Choose a reason for hiding this comment

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

As in my PR #1895 I recommend using env!("CARGO")...or we can just let me PR fix it up.

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.

Test failures in azure_core_derive compilation-tests
2 participants