Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
chore: self mutation (build.diff)

Signed-off-by: monada-bot[bot] <monabot@monada.co>
  • Loading branch information
skyrpex committed Nov 6, 2024
1 parent cb705f3 commit 051031f
Show file tree
Hide file tree
Showing 70 changed files with 88 additions and 84 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ cors.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ build-failure.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ pull-failure.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ aws-layer.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ retention_period.main.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ init.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ secret-ref.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ section.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ api_valid_path.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ root/cloud.TestRunner
root/Default
pass ─ app.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ asynchronous_model_implicit_await_in_functions.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_alias.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_awscdk.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_cdk8s.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_cdktf.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_extend_non_entry.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_local_dir.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_local_normalization.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bring_projen.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ bypass_return.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ capture_primitives.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ captures.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ casting.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ display name of wing resource: no display name
root/Default/WingResource
pass ─ construct-base.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ container_types.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ custom_obj_id.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ expressions_binary_operators.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ file_counter.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ for x in (z*2)..0 { ... } <=> x = 2
1
pass ─ for_loop.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
hi
pass ─ forward_decl.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ function_optional_arguments.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ function_type.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ function_variadic_arguments.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```log
pass ─ hello.test.wsim (no tests)
Tests 1 passed (1)
Tests (0)
Snapshots 1 skipped
Test Files 1 passed (1)
Duration <DURATION>
Expand Down
Loading

0 comments on commit 051031f

Please sign in to comment.