Skip to content

Commit

Permalink
bug: corrected non-skipped tests collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun0157 committed Jun 26, 2024
1 parent 21e71f2 commit 25f7100
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
22 changes: 18 additions & 4 deletions tests/bundles/auto-tests.zzb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ requests:
$.args.foo1: bar1
$.args.foo2: bar2

get-with-params-skip:
method: GET
url: /get
params:
foo1: bar1
foo2: bar2
tests: # old way of specifying json tests
status: { $eq: 0, $skip: true }
$h.Content-type: { $eq: random-test, $skip: true }
json:
$.args:
$skip: false
$tests:
$.foo1 : bar2
$.foo2: bar1

get-with-params-no-value-positive:
method: GET
url: /get
Expand All @@ -53,7 +69,7 @@ requests:
- { name: foo2, value: multi-1 }
- { name: foo2, value: multi-2 }
tests:
$.args.foo1: { $eq: bar1, $skip: true }
$.args.foo1: bar1
$.args.foo2: { $eq: ["multi-1", "multi-2"] }

get-with-params-values-as-array-positive:
Expand Down Expand Up @@ -251,9 +267,7 @@ requests:
$.data.lastName: { $exists: true }
# $.data.middleName: { $exists: true, $type: "null" }
$.data.middleName: null
$.data.otherName:
$tests:
$.: { $exists: true, $type: undefined, $skip: true }
$.data.otherName: { $exists: false, $type: undefined }
# stress: ensure corner cases don't crash
$.data.otherName.value: { $exists: false } # don't recurse down undefined
$.data.middleName.value: { $exists: false } # don't recurse down null
Expand Down
17 changes: 7 additions & 10 deletions tests/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,21 @@ function allNegative(res: SpecResult, numTests: number): string[] {

function allSkipped(res: SpecResult, numTests: number): string[] {
const errors: string[] = [];

const [_passed, skipped, all] = getResultData(res);
if (all !== numTests) errors.push(`expected ${numTests} tests, got ${all}\n`);
if (skipped === all) return errors;

function getSkippedTests(res: SpecResult, spec: string): string[] {
const skippedTests: string[] = [];
if (!res.skipped) return skippedTests;

const rootSkipped = res.results;
skippedTests.push(...rootSkipped.map((r) => formatTestResult(r, spec, true)));
function getRanTests(res: SpecResult, spec: string): string[] {
const nonSkippedTests: string[] = [];
if (res.skipped) return nonSkippedTests;

for (const s of res.subResults) skippedTests.push(...getSkippedTests(s, spec + " > " + s.spec));
nonSkippedTests.push(...res.results.map((r) => formatTestResult(r, spec, res.skipped)));
for (const s of res.subResults) nonSkippedTests.push(...getRanTests(s, spec + " > " + s.spec));

return skippedTests;
return nonSkippedTests;
}

errors.push(...getSkippedTests(res, res.spec ?? ""));
errors.push(...getRanTests(res, res.spec ?? ""));
return errors;
}

Expand Down

0 comments on commit 25f7100

Please sign in to comment.