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

fix(cli): not to show 1 test when no tests are in the file #7205

Merged
merged 8 commits into from
Nov 6, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`printing test reports > results for files with no tests 1`] = `"pass ─ hello.w (no tests)"`;

exports[`printing test reports > verbose traces are not shown if debug mode is disabled 1`] = `
"fail ┌ hello.w » root/env0/test:test
│ sleeping for 500 ms
Expand Down
19 changes: 15 additions & 4 deletions packages/winglang/src/commands/test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from "path";
import { BuiltinPlatform } from "@winglang/compiler";
import { LogLevel, TestResult, TraceType } from "@winglang/sdk/lib/std";
import chalk from "chalk";
import { describe, test, expect, beforeEach, afterEach, vi, SpyInstance } from "vitest";
import { describe, test, expect, beforeEach, afterEach, vi, MockInstance } from "vitest";
import { filterTests, renderTestReport, collectTestFiles, test as wingTest } from ".";
import * as resultsFn from "./results";
import { SnapshotMode } from "./snapshots";
Expand Down Expand Up @@ -45,10 +45,21 @@ describe("printing test reports", () => {
expect(testReport).toMatchSnapshot();
expect(testReport).toContain("Push (message=cool)");
});

test("results for files with no tests", async () => {
let inputResults: TestResult[] = [];
const testReport = await renderTestReport("hello.w", inputResults);

expect(testReport).toMatchSnapshot();
expect(testReport).toContain("(no tests)");

// verify that the the no dummy test results were added
expect(inputResults).toHaveLength(0);
});
});

describe("wing test (custom platform)", () => {
let logSpy: SpyInstance;
let logSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down Expand Up @@ -208,7 +219,7 @@ describe("collectTestFiles", () => {
});

describe("output-file option", () => {
let writeResultsSpy: SpyInstance;
let writeResultsSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down Expand Up @@ -304,7 +315,7 @@ describe("test-filter option", () => {
});

describe("retry and parallel options", () => {
let logSpy: SpyInstance;
let logSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down
17 changes: 4 additions & 13 deletions packages/winglang/src/commands/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,10 @@ export async function renderTestReport(
0
);

// if there are no inflight tests, add a dummy "pass" result
// return early if there are no tests, return a pass output
// to indicate that compilation and preflight checks passed
if (results.length === 0) {
results.push({
pass: true,
path: "",
traces: [],
});
return `${chalk.green("pass")} ─ ${basename(entrypoint)} ${chalk.gray("(no tests)")}`;
}

for (const result of results.sort(sortTests)) {
Expand Down Expand Up @@ -307,13 +303,8 @@ export async function renderTestReport(
}

firstRow.push(basename(entrypoint));

if (result.path?.length > 0) {
firstRow.push(chalk.gray("»"));
firstRow.push(chalk.whiteBright(result.path.padEnd(longestPath)));
} else {
firstRow.push(chalk.gray("(no tests)"));
}
firstRow.push(chalk.gray("»"));
firstRow.push(chalk.whiteBright(result.path.padEnd(longestPath)));

// okay we are ready to print the test result

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions tests/doc_examples/valid/03-functions.md_example_1/main.w

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions tests/doc_examples/valid/04-flow-controls.md_example_1/main.w

This file was deleted.

16 changes: 0 additions & 16 deletions tests/doc_examples/valid/04-flow-controls.md_example_2/main.w

This file was deleted.

23 changes: 0 additions & 23 deletions tests/doc_examples/valid/04-flow-controls.md_example_3/main.w

This file was deleted.

28 changes: 0 additions & 28 deletions tests/doc_examples/valid/04-flow-controls.md_example_4/main.w

This file was deleted.

4 changes: 0 additions & 4 deletions tests/doc_examples/valid/05-optionality.md_example_1/main.w

This file was deleted.

23 changes: 0 additions & 23 deletions tests/doc_examples/valid/06-json.md_example_1/main.w

This file was deleted.

10 changes: 0 additions & 10 deletions tests/doc_examples/valid/07-structs.md_example_1/main.w

This file was deleted.

12 changes: 0 additions & 12 deletions tests/doc_examples/valid/07-structs.md_example_2/main.w

This file was deleted.

21 changes: 0 additions & 21 deletions tests/doc_examples/valid/07-structs.md_example_3/main.w

This file was deleted.

17 changes: 0 additions & 17 deletions tests/doc_examples/valid/07-structs.md_example_4/main.w

This file was deleted.

32 changes: 0 additions & 32 deletions tests/doc_examples/valid/08-classes.md_example_4/main.w

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading