Merge pull request #15159 from github/koesie10/csharp-model-editor-tests

C#: Classify test support files in model editor queries
This commit is contained in:
Koen Vlaswinkel
2023-12-20 10:54:24 +01:00
committed by GitHub
2 changed files with 13 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ private import ModelEditor
* A class of effectively public callables from source code.
*/
class PublicEndpointFromSource extends Endpoint {
PublicEndpointFromSource() { this.fromSource() and not this.getFile() instanceof TestFile }
PublicEndpointFromSource() { this.fromSource() and not this.getFile() instanceof TestRelatedFile }
override predicate isSource() { this instanceof SourceCallable }

View File

@@ -110,9 +110,9 @@ string supportedType(Endpoint endpoint) {
}
string methodClassification(Call method) {
method.getFile() instanceof TestFile and result = "test"
method.getFile() instanceof TestRelatedFile and result = "test"
or
not method.getFile() instanceof TestFile and
not method.getFile() instanceof TestRelatedFile and
result = "source"
}
@@ -129,3 +129,13 @@ private string qualifiedTypeName(string namespace, Type t) {
private string qualifiedCallableName(string namespace, string type, Callable c) {
exists(string name | hasQualifiedMethodName(c, namespace, type, name) | result = name)
}
/** A file that is either a test file or is only used in tests. */
class TestRelatedFile extends File {
TestRelatedFile() {
this instanceof TestFile
or
this.getAbsolutePath().matches(["%/test/%", "%/tests/%"]) and
not this.getAbsolutePath().matches("%/ql/test/%") // allows our test cases to work
}
}