-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
With the CodeQL CLI, the handling of toString() methods in QL changes. The default compilation mode in Odasa was that entity classes that don't declare a toString() inherit the default implicit none() behavior. In contrast, the new CodeQL CLI compiles with --default-to-string by default, which corresponds to a default behavior that could be expressed as
String toString() { result = "" }
These differences also apply between odasa qltest and (the yet-to-be-released) codeql test run. There are a few existing tests where this difference matters -- namely where a missing toString() definition in the library and/or test code previously made some row disappear from the output due to not having any string representation. Thus the existing .expected file will not contain these rows, but codeql test run will produce them, making the test fail.
It has been decided that this ought to be fixed by making sure that tests always declare all relevant toString() methods, such that their output is independent of the compilation mode.
For JavaScript, the tests affected are:
-
ql/javascript/ql/test/library-tests/XML/XMLParent_getTextValue.ql
Please fix these -- ideally by making sure the relevant entity classes have toString() methods, but in a pinch just by injecting some and a.toString() != "" conditions in the select clauses.
To test that your fix works:
- check out branch
pr/test-extractofgit.semmle.com/henning/code- if this branch doesn't exist, it might be that #35764 has been merged, in which case you can just use
Semmle/code/master.
- if this branch doesn't exist, it might be that #35764 has been merged, in which case you can just use
- build
target/intree/codeql. - try running your test both with
codeql test run path/to/test.qland withcodeql test run --no-default-to-string path/to/test.ql.
(Once all the tests have been updated, we will modify the behavior of odasa qltest appropriately, so a new divergence between the tools won't arise).