diff --git a/swift/ql/test/TestUtils.qll b/swift/ql/test/TestUtils.qll index f1f47eda8087..9b5429f8ba92 100644 --- a/swift/ql/test/TestUtils.qll +++ b/swift/ql/test/TestUtils.qll @@ -6,7 +6,8 @@ import codeql.swift.elements.expr.internal.DotSyntaxCallExpr cached predicate toBeTested(Element e) { - e instanceof File + e instanceof File and + (exists(e.(File).getRelativePath()) or e instanceof UnknownFile) or e instanceof ParameterizedProtocolType or diff --git a/swift/ql/test/library-tests/elements/decl/enumdecl/enumdecl.ql b/swift/ql/test/library-tests/elements/decl/enumdecl/enumdecl.ql index dba88e6009d3..5e4c0c6035f2 100644 --- a/swift/ql/test/library-tests/elements/decl/enumdecl/enumdecl.ql +++ b/swift/ql/test/library-tests/elements/decl/enumdecl/enumdecl.ql @@ -21,5 +21,5 @@ string describe(Decl d) { } from Decl d -where d.getLocation().getFile().getName() != "" +where exists(d.getLocation().getFile().getRelativePath()) select d, strictconcat(describe(d), ", ") diff --git a/swift/ql/test/library-tests/elements/decl/function/function.ql b/swift/ql/test/library-tests/elements/decl/function/function.ql index 9468929d1942..fbd47a20f4bc 100644 --- a/swift/ql/test/library-tests/elements/decl/function/function.ql +++ b/swift/ql/test/library-tests/elements/decl/function/function.ql @@ -27,6 +27,6 @@ string describe(Function f) { from Function f where - not f.getFile() instanceof UnknownFile and + exists(f.getFile().getRelativePath()) and not f.getName().matches("%init%") select f, concat(describe(f), ", ") diff --git a/swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.ql b/swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.ql index 713e471d15fb..68a0184cdcdd 100644 --- a/swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.ql +++ b/swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.ql @@ -16,7 +16,7 @@ string describe(Type t) { from VarDecl v, Type t where - v.getLocation().getFile().getBaseName() != "" and + exists(v.getLocation().getFile().getRelativePath()) and not v.getName() = "self" and t = v.getType() select v, t.toString(), concat(describe(t), ", ") diff --git a/swift/ql/test/library-tests/elements/type/nominaltype/nominaltypedecl.ql b/swift/ql/test/library-tests/elements/type/nominaltype/nominaltypedecl.ql index 83fb434a7f7b..cec74fbf3927 100644 --- a/swift/ql/test/library-tests/elements/type/nominaltype/nominaltypedecl.ql +++ b/swift/ql/test/library-tests/elements/type/nominaltype/nominaltypedecl.ql @@ -14,7 +14,7 @@ string describe(TypeDecl td) { from VarDecl v, TypeDecl td where - v.getLocation().getFile().getBaseName() != "" and + exists(v.getLocation().getFile().getRelativePath()) and not v.getName() = "self" and ( td = v.getType().(NominalType).getDeclaration() or diff --git a/swift/ql/test/library-tests/elements/type/numerictype/numerictype.ql b/swift/ql/test/library-tests/elements/type/numerictype/numerictype.ql index 7f3fb4591f84..73f11673a5f5 100644 --- a/swift/ql/test/library-tests/elements/type/numerictype/numerictype.ql +++ b/swift/ql/test/library-tests/elements/type/numerictype/numerictype.ql @@ -14,6 +14,6 @@ string describe(Type t) { from VarDecl v, Type t where - v.getLocation().getFile().getBaseName() != "" and + exists(v.getLocation().getFile().getRelativePath()) and t = v.getType() select v, t.toString(), concat(describe(t), ", ") diff --git a/swift/ql/test/library-tests/elements/type/pointertypes/pointertypes.ql b/swift/ql/test/library-tests/elements/type/pointertypes/pointertypes.ql index fe0157fa6c74..9232b24167cc 100644 --- a/swift/ql/test/library-tests/elements/type/pointertypes/pointertypes.ql +++ b/swift/ql/test/library-tests/elements/type/pointertypes/pointertypes.ql @@ -22,6 +22,6 @@ string describe(Type t) { from VarDecl v, Type t where - v.getLocation().getFile().getBaseName() != "" and + exists(v.getLocation().getFile().getRelativePath()) and t = v.getType() select v, t.toString(), strictconcat(describe(t), ", ") diff --git a/swift/ql/test/query-tests/Diagnostics/Info.ql b/swift/ql/test/query-tests/Diagnostics/Info.ql index 765ee15c737c..dd7e316c8777 100644 --- a/swift/ql/test/query-tests/Diagnostics/Info.ql +++ b/swift/ql/test/query-tests/Diagnostics/Info.ql @@ -3,4 +3,5 @@ import swift string describe(File f) { (f.isSuccessfullyExtracted() and result = "isSuccessfullyExtracted") } from File f +where exists(f.getRelativePath()) or f instanceof UnknownFile select f, concat(f.getRelativePath(), ", "), concat(describe(f), ", ")