C#: Extend TestFile instead of separate class

This commit is contained in:
Koen Vlaswinkel
2023-12-19 16:37:49 +01:00
parent d22acfb449
commit 0f71df9c41
2 changed files with 3 additions and 10 deletions

View File

@@ -7,11 +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 and
not this.getFile() instanceof TestSupportFile
}
PublicEndpointFromSource() { this.fromSource() and not this.getFile() instanceof TestFile }
override predicate isSource() { this instanceof SourceCallable }

View File

@@ -110,11 +110,9 @@ string supportedType(Endpoint endpoint) {
}
string methodClassification(Call method) {
(method.getFile() instanceof TestFile or method.getFile() instanceof TestSupportFile) and
result = "test"
method.getFile() instanceof TestFile and result = "test"
or
not method.getFile() instanceof TestFile and
not method.getFile() instanceof TestSupportFile and
result = "source"
}
@@ -133,9 +131,8 @@ private string qualifiedCallableName(string namespace, string type, Callable c)
}
/** A file that doesn't contain tests itself, but is only used in tests. */
class TestSupportFile extends File {
class TestSupportFile extends TestFile {
TestSupportFile() {
not this instanceof TestFile and
this.getAbsolutePath().matches(["%/test/%", "%/tests/%"]) and
not this.getAbsolutePath().matches("%/ql/test/%") // allows our test cases to work
}