Fix typespec_derive compilation tests #1899
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1896
There were two problems here, and I've fixed both:
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
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.