Skip to content

Test compilation errors appear in output diff #819

@Marcono1234

Description

@Marcono1234

Version
CodeQL CLI v2.5.0
Extension version: v1.4.5

Describe the bug
When compilation of a test fails, the extension currently creates an output diff between the expected output and the compilation error, which is pretty pointless and confusing. E.g.:

--- expected
+++ actual
@@ -1,12 +1,1 @@
-| Expressions.java:5:9:5:18 | toString(...) |
-| Expressions.java:9:9:9:13 | ...=... |
-| Expressions.java:10:9:10:11 | ...++ |
-| Expressions.java:11:9:11:20 | new Object(...) |
-| Expressions.java:14:9:14:28 | clone(...) |
+ERROR: no viable parse for input 'a', expecting one of : 'boolean', 'class', 'newtype', 'date', 'float', 'from', 'import', 'int', 'module', 'predicate', 'select', 'string', 'where', Lowerid, Upperid, Atlowerid (Expressions.ql:6,1-2)

It looks like the underlying issue might be caused by the CodeQL CLI which reports this as diff. It appears this is currently 'misused' to perform tests on CodeQL itself, see #608 (comment).
Regardless of whether that is intended or not, the extension could inspect the failureStage of the response, only if it is "failureStage" : "RESULT" the diff should be shown.

To Reproduce

  1. Create an .expected file
  2. Create a query test file containing a compilation error
  3. Run codeql test run --format=json

Expected behavior
Only the compilation error is reported, the diff is not shown.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions