Skip to content

Commit

Permalink
Merge coverage CI showing right percentage (#759)
Browse files Browse the repository at this point in the history
* fix: evaluated_operations not counting x-ignorable

Signed-off-by: Tokesh <[email protected]>

* adding filter

Signed-off-by: Tokesh <[email protected]>

* chore: lint fix and added comments

Signed-off-by: Tokesh <[email protected]>

* chore: disable linter checks

Signed-off-by: Tokesh <[email protected]>

* chore: deleting not necessary line

Signed-off-by: Tokesh <[email protected]>

---------

Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh authored Jan 2, 2025
1 parent 24872ec commit 3d88921
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tools/src/tester/TestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,30 @@ export default class TestResults {
}

evaluated_operations(): Operation[] {
if (this._evaluated_operations !== undefined) return this._evaluated_operations
this._evaluated_operations = _.uniqWith(_.compact(_.flatMap(this._evaluations.evaluations, (evaluation) =>
_.map(evaluation.chapters, (chapter) => chapter.operation)
)), isEqual)
return this._evaluated_operations
if (this._evaluated_operations !== undefined) return this._evaluated_operations;

const all_operations = _.uniqWith(
_.compact(
_.flatMap(this._evaluations.evaluations, (evaluation) =>
_.map(evaluation.chapters, (chapter) => chapter.operation)
)
),
isEqual
);

// Filter operations to exclude paths or methods not in the spec or marked as 'x-ignorable'.
this._evaluated_operations = all_operations.filter((operation) => {
const spec_path = this._spec.spec().paths[operation.path];
if (!spec_path) return true;

const method_spec = (spec_path as Record<string, any>)[operation.method.toLowerCase()];
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!method_spec) return true;

return method_spec['x-ignorable'] !== true;
});

return this._evaluated_operations;
}

unevaluated_operations(): Operation[] {
Expand Down Expand Up @@ -86,4 +105,4 @@ export default class TestResults {
write_coverage(file_path: string): void {
write_json(file_path, this.test_coverage())
}
}
}

0 comments on commit 3d88921

Please sign in to comment.