Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suppressions] Add tests to improve code coverage #29163

Merged
merged 4 commits into from
May 20, 2024
Merged
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
15 changes: 11 additions & 4 deletions .github/workflows/_eng-tools-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
test:
strategy:
matrix:
runs-on: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
node-version: [18, 20]
exclude:
- runs-on: ubuntu-latest
- os: ubuntu-latest
node-version: 20
- runs-on: windows-latest
- os: windows-latest
node-version: 18

runs-on: ${{ matrix.runs-on }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
Expand All @@ -47,3 +47,10 @@ jobs:
- run: npm run test:ci
shell: pwsh
working-directory: ./eng/tools/${{ inputs.package }}

- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-${{ matrix.os }}-${{ matrix.node-version }}
path: ./eng/tools/${{ inputs.package }}/coverage
if-no-files-found: ignore
42 changes: 42 additions & 0 deletions eng/tools/suppressions/test/suppressions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,48 @@ test("one suppression match directory", () => {
]);
});

test("paths match first", () => {
const suppressions: Suppression[] = getSuppressionsFromYaml(
"TestTool",
"Microsoft.Foo",
"suppressions.yaml",
"- tool: TestTool\n paths:\n - Microsoft.Foo\n - Microsoft.Bar\n reason: test",
);
expect(suppressions).toEqual([
{
tool: "TestTool",
paths: ["Microsoft.Foo", "Microsoft.Bar"],
reason: "test",
},
]);
});

test("paths match second", () => {
const suppressions: Suppression[] = getSuppressionsFromYaml(
"TestTool",
"Microsoft.Bar",
"suppressions.yaml",
"- tool: TestTool\n paths:\n - Microsoft.Foo\n - Microsoft.Bar\n reason: test",
);
expect(suppressions).toEqual([
{
tool: "TestTool",
paths: ["Microsoft.Foo", "Microsoft.Bar"],
reason: "test",
},
]);
});

test("paths match none", () => {
const suppressions: Suppression[] = getSuppressionsFromYaml(
"TestTool",
"Microsoft.Baz",
"suppressions.yaml",
"- tool: TestTool\n paths:\n - Microsoft.Foo\n - Microsoft.Bar\n reason: test",
);
expect(suppressions).toEqual([]);
});

test("path and paths match first", () => {
const suppressions: Suppression[] = getSuppressionsFromYaml(
"TestTool",
Expand Down