Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions rust/ql/test/library-tests/type-inference/type-inference.ql
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ module ResolveTest implements TestSig {
module TypeTest implements TestSig {
string getARelevantTag() { result = ["type", "certainType"] }

predicate tagIsOptional(string expectedTag) { expectedTag = "type" }

predicate hasActualResult(Location location, string element, string tag, string value) { none() }

predicate hasOptionalResult(Location location, string element, string tag, string value) {
Expand Down
59 changes: 27 additions & 32 deletions shared/util/codeql/util/test/InlineExpectationsTest.qll
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ module Make<InlineExpectationsTestSig Impl> {
bindingset[expectedTag, actualTag]
default predicate tagMatches(string expectedTag, string actualTag) { expectedTag = actualTag }

/** Holds if expectations marked with `expectedTag` are optional. */
/** Holds if expectations marked with `expectedTag` are ignored. */
bindingset[expectedTag]
default predicate tagIsOptional(string expectedTag) { none() }
default predicate tagIsIgnored(string expectedTag) { none() }

/**
* Holds if expected value `expectedValue` matches actual value `actualValue`.
Expand Down Expand Up @@ -223,8 +223,7 @@ module Make<InlineExpectationsTestSig Impl> {
exists(ValidTestExpectation expectation |
not exists(ActualTestResult actualResult | expectation.matchesActualResult(actualResult)) and
expectation.getTag() = TestImpl::getARelevantTag() and
element = expectation and
not expectation.isOptional()
element = expectation
|
expectation instanceof GoodTestExpectation and
message = "Missing result: " + expectation.getExpectationText()
Expand Down Expand Up @@ -253,7 +252,8 @@ module Make<InlineExpectationsTestSig Impl> {
exists(TColumn column, string tags |
getAnExpectation(comment, column, _, tags, value) and
tag = tags.splitAt(",") and
knownFailure = getColumnString(column)
knownFailure = getColumnString(column) and
not TestImpl::tagIsIgnored(tag)
)
} or
TInvalidExpectation(Impl::ExpectationComment comment, string expectation) {
Expand Down Expand Up @@ -338,8 +338,6 @@ module Make<InlineExpectationsTestSig Impl> {
TestImpl::tagMatches(this.getTag(), actualResult.getTag()) and
TestImpl::valueMatches(this.getValue(), actualResult.getValue())
}

predicate isOptional() { TestImpl::tagIsOptional(tag) }
}

// Note: These next three classes correspond to all the possible values of type `TColumn`.
Expand Down Expand Up @@ -428,6 +426,12 @@ module Make<InlineExpectationsTestSig Impl> {
result = TestImpl1::getARelevantTag() or result = TestImpl2::getARelevantTag()
}

bindingset[expectedTag]
predicate tagIsIgnored(string expectedTag) {
TestImpl1::tagIsIgnored(expectedTag) or
TestImpl2::tagIsIgnored(expectedTag)
}

predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
TestImpl1::hasActualResult(location, element, tag, value)
or
Expand All @@ -447,16 +451,13 @@ module Make<InlineExpectationsTestSig Impl> {
module MergeTests3<TestSig TestImpl1, TestSig TestImpl2, TestSig TestImpl3> implements TestSig {
private module M = MergeTests<MergeTests<TestImpl1, TestImpl2>, TestImpl3>;

bindingset[result]
string getARelevantTag() { result = M::getARelevantTag() }
predicate getARelevantTag = M::getARelevantTag/0;

predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
M::hasActualResult(location, element, tag, value)
}
predicate tagIsIgnored = M::tagIsIgnored/1;

predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
M::hasOptionalResult(location, element, tag, value)
}
predicate hasActualResult = M::hasActualResult/4;

predicate hasOptionalResult = M::hasOptionalResult/4;
}

/**
Expand All @@ -467,16 +468,13 @@ module Make<InlineExpectationsTestSig Impl> {
{
private module M = MergeTests<MergeTests3<TestImpl1, TestImpl2, TestImpl3>, TestImpl4>;

bindingset[result]
string getARelevantTag() { result = M::getARelevantTag() }
predicate getARelevantTag = M::getARelevantTag/0;

predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
M::hasActualResult(location, element, tag, value)
}
predicate tagIsIgnored = M::tagIsIgnored/1;

predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
M::hasOptionalResult(location, element, tag, value)
}
predicate hasActualResult = M::hasActualResult/4;

predicate hasOptionalResult = M::hasOptionalResult/4;
}

/**
Expand All @@ -489,16 +487,13 @@ module Make<InlineExpectationsTestSig Impl> {
private module M =
MergeTests<MergeTests4<TestImpl1, TestImpl2, TestImpl3, TestImpl4>, TestImpl5>;

bindingset[result]
string getARelevantTag() { result = M::getARelevantTag() }
predicate getARelevantTag = M::getARelevantTag/0;

predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
M::hasActualResult(location, element, tag, value)
}
predicate tagIsIgnored = M::tagIsIgnored/1;

predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
M::hasOptionalResult(location, element, tag, value)
}
predicate hasActualResult = M::hasActualResult/4;

predicate hasOptionalResult = M::hasOptionalResult/4;
}

/**
Expand Down Expand Up @@ -870,7 +865,7 @@ module TestPostProcessing {
}

bindingset[expectedTag]
predicate tagIsOptional(string expectedTag) {
predicate tagIsIgnored(string expectedTag) {
exists(getQueryKind()) and
(
// ignore irrelevant tags
Expand Down
Loading