Skip to content

Commit e58a8d8

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

2 files changed

Lines changed: 26 additions & 32 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: 26 additions & 30 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`.
@@ -253,7 +253,8 @@ module Make<InlineExpectationsTestSig Impl> {
253253
exists(TColumn column, string tags |
254254
getAnExpectation(comment, column, _, tags, value) and
255255
tag = tags.splitAt(",") and
256-
knownFailure = getColumnString(column)
256+
knownFailure = getColumnString(column) and
257+
not TestImpl::tagIsIgnored(tag)
257258
)
258259
} or
259260
TInvalidExpectation(Impl::ExpectationComment comment, string expectation) {
@@ -338,8 +339,6 @@ module Make<InlineExpectationsTestSig Impl> {
338339
TestImpl::tagMatches(this.getTag(), actualResult.getTag()) and
339340
TestImpl::valueMatches(this.getValue(), actualResult.getValue())
340341
}
341-
342-
predicate isOptional() { TestImpl::tagIsOptional(tag) }
343342
}
344343

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

430+
bindingset[expectedTag]
431+
predicate tagIsIgnored(string expectedTag) {
432+
TestImpl1::tagIsIgnored(expectedTag) or
433+
TestImpl2::tagIsIgnored(expectedTag)
434+
}
435+
431436
predicate hasActualResult(Impl::Location location, string element, string tag, string value) {
432437
TestImpl1::hasActualResult(location, element, tag, value)
433438
or
@@ -447,16 +452,13 @@ module Make<InlineExpectationsTestSig Impl> {
447452
module MergeTests3<TestSig TestImpl1, TestSig TestImpl2, TestSig TestImpl3> implements TestSig {
448453
private module M = MergeTests<MergeTests<TestImpl1, TestImpl2>, TestImpl3>;
449454

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

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

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

462464
/**
@@ -467,16 +469,13 @@ module Make<InlineExpectationsTestSig Impl> {
467469
{
468470
private module M = MergeTests<MergeTests3<TestImpl1, TestImpl2, TestImpl3>, TestImpl4>;
469471

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

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

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

482481
/**
@@ -489,16 +488,13 @@ module Make<InlineExpectationsTestSig Impl> {
489488
private module M =
490489
MergeTests<MergeTests4<TestImpl1, TestImpl2, TestImpl3, TestImpl4>, TestImpl5>;
491490

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

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

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

504500
/**
@@ -870,7 +866,7 @@ module TestPostProcessing {
870866
}
871867

872868
bindingset[expectedTag]
873-
predicate tagIsOptional(string expectedTag) {
869+
predicate tagIsIgnored(string expectedTag) {
874870
exists(getQueryKind()) and
875871
(
876872
// ignore irrelevant tags

0 commit comments

Comments
 (0)