Skip to content

Commit 80ccdcc

Browse files
committed
Inline test expectations: Rename tagIsOptional to tagIsIgnored
1 parent 68be006 commit 80ccdcc

2 files changed

Lines changed: 27 additions & 34 deletions

File tree

rust/ql/test/library-tests/type-inference/type-inference.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ module ResolveTest implements TestSig {
6262
module TypeTest implements TestSig {
6363
string getARelevantTag() { result = ["type", "certainType"] }
6464

65-
predicate tagIsOptional(string expectedTag) { expectedTag = "type" }
66-
6765
predicate hasActualResult(Location location, string element, string tag, string value) { none() }
6866

6967
predicate hasOptionalResult(Location location, string element, string tag, string value) {

shared/util/codeql/util/test/InlineExpectationsTest.qll

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ module Make<InlineExpectationsTestSig Impl> {
146146
bindingset[expectedTag, actualTag]
147147
default predicate tagMatches(string expectedTag, string actualTag) { expectedTag = actualTag }
148148

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

153153
/**
154154
* Holds if expected value `expectedValue` matches actual value `actualValue`.
@@ -223,8 +223,7 @@ module Make<InlineExpectationsTestSig Impl> {
223223
exists(ValidTestExpectation expectation |
224224
not exists(ActualTestResult actualResult | expectation.matchesActualResult(actualResult)) and
225225
expectation.getTag() = TestImpl::getARelevantTag() and
226-
element = expectation and
227-
not expectation.isOptional()
226+
element = expectation
228227
|
229228
expectation instanceof GoodTestExpectation and
230229
message = "Missing result: " + expectation.getExpectationText()
@@ -253,7 +252,8 @@ module Make<InlineExpectationsTestSig Impl> {
253252
exists(TColumn column, string tags |
254253
getAnExpectation(comment, column, _, tags, value) and
255254
tag = tags.splitAt(",") and
256-
knownFailure = getColumnString(column)
255+
knownFailure = getColumnString(column) and
256+
not TestImpl::tagIsIgnored(tag)
257257
)
258258
} or
259259
TInvalidExpectation(Impl::ExpectationComment comment, string expectation) {
@@ -338,8 +338,6 @@ module Make<InlineExpectationsTestSig Impl> {
338338
TestImpl::tagMatches(this.getTag(), actualResult.getTag()) and
339339
TestImpl::valueMatches(this.getValue(), actualResult.getValue())
340340
}
341-
342-
predicate isOptional() { TestImpl::tagIsOptional(tag) }
343341
}
344342

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

429+
bindingset[expectedTag]
430+
predicate tagIsIgnored(string expectedTag) {
431+
TestImpl1::tagIsIgnored(expectedTag) or
432+
TestImpl2::tagIsIgnored(expectedTag)
433+
}
434+
431435
predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
432436
TestImpl1::hasActualResult(location, element, tag, value)
433437
or
@@ -447,16 +451,13 @@ module Make<InlineExpectationsTestSig Impl> {
447451
module MergeTests3<TestSig TestImpl1, TestSig TestImpl2, TestSig TestImpl3> implements TestSig {
448452
private module M = MergeTests<MergeTests<TestImpl1, TestImpl2>, TestImpl3>;
449453

450-
bindingset[result]
451-
string getARelevantTag() { result = M::getARelevantTag() }
454+
predicate getARelevantTag = M::getARelevantTag/0;
452455

453-
predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
454-
M::hasActualResult(location, element, tag, value)
455-
}
456+
predicate tagIsIgnored = M::tagIsIgnored/1;
456457

457-
predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
458-
M::hasOptionalResult(location, element, tag, value)
459-
}
458+
predicate hasActualResult = M::hasActualResult/4;
459+
460+
predicate hasOptionalResult = M::hasOptionalResult/4;
460461
}
461462

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

470-
bindingset[result]
471-
string getARelevantTag() { result = M::getARelevantTag() }
471+
predicate getARelevantTag = M::getARelevantTag/0;
472472

473-
predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
474-
M::hasActualResult(location, element, tag, value)
475-
}
473+
predicate tagIsIgnored = M::tagIsIgnored/1;
476474

477-
predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
478-
M::hasOptionalResult(location, element, tag, value)
479-
}
475+
predicate hasActualResult = M::hasActualResult/4;
476+
477+
predicate hasOptionalResult = M::hasOptionalResult/4;
480478
}
481479

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

492-
bindingset[result]
493-
string getARelevantTag() { result = M::getARelevantTag() }
490+
predicate getARelevantTag = M::getARelevantTag/0;
494491

495-
predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
496-
M::hasActualResult(location, element, tag, value)
497-
}
492+
predicate tagIsIgnored = M::tagIsIgnored/1;
498493

499-
predicate hasOptionalResult(Impl::Location location, string element, string tag, string value) {
500-
M::hasOptionalResult(location, element, tag, value)
501-
}
494+
predicate hasActualResult = M::hasActualResult/4;
495+
496+
predicate hasOptionalResult = M::hasOptionalResult/4;
502497
}
503498

504499
/**
@@ -870,7 +865,7 @@ module TestPostProcessing {
870865
}
871866

872867
bindingset[expectedTag]
873-
predicate tagIsOptional(string expectedTag) {
868+
predicate tagIsIgnored(string expectedTag) {
874869
exists(getQueryKind()) and
875870
(
876871
// ignore irrelevant tags

0 commit comments

Comments
 (0)