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

show test logs in CI #157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- run: pnpm add --global ember-cli yarn
- run: pnpm vitest --testNamePattern "${{ matrix.slow-test }}"
- run: DEBUG=addon-blueprint:utils pnpm vitest --testNamePattern "${{ matrix.slow-test }}"
working-directory: tests
33 changes: 21 additions & 12 deletions pnpm-lock.yaml

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

13 changes: 6 additions & 7 deletions tests/helpers/meta-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import debug from 'debug';
import assert from 'node:assert';
import fs from 'node:fs/promises';
import path from 'node:path';
Expand All @@ -6,16 +7,16 @@ import { matchesFixture } from './assertions.js';
import { copyFixture } from './fixtures.js';
import { createAddon, createTmp, install, runScript } from './utils.js';

const DEBUG = process.env.DEBUG === 'true';
const debugLog = debug('addon-blueprint:temp');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temp feels like a goofy label


/**
* Helps with common addon testing concerns.
* tl;dr:
* it's a wrapper around ember addon -b (so we can pass our flags with less duplication)
* it lets us set compare against a fixture set / scenario
*
* To DEBUG the intermediate output (in tmp),
* re-start your tests with `DEBUG=true`, and the tmpdir will be printed
* To debug the intermediate output (in tmp),
* re-start your tests with `DEBUG=addon-blueprint:temp`, and the tmpdir will be printed
* as well as the `clean` function will not run so that if a test finishes,
* you can still inspect the folder contents
*
Expand All @@ -42,9 +43,7 @@ export class AddonHelper {
async setup() {
this.#tmpDir = await createTmp();

if (DEBUG) {
console.debug(`Debug test repo at ${this.#tmpDir}`);
}
debugLog(`Debug test repo at ${this.#tmpDir}`);

let args = [...this.#args];
let needsPackageManagerSet =
Expand Down Expand Up @@ -83,7 +82,7 @@ export class AddonHelper {
}

async clean() {
if (DEBUG) return;
if (process.env.SKIP_CLEANUP) return;

assert(
this.#tmpDir,
Expand Down
16 changes: 10 additions & 6 deletions tests/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import debug from 'debug';
import { type Options, execa } from 'execa';
import fse from 'fs-extra';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const DEBUG = process.env.DEBUG === 'true';
const debugLog = debug('addon-blueprint:utils');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addon-blueprint:test-utils maybe? To not suggest users they get debug output when running the bp itself, since this is only effective when running the bp's tests...


const __dirname = path.dirname(fileURLToPath(import.meta.url));

// repo-root
Expand Down Expand Up @@ -91,7 +93,11 @@ export async function runScript({
let promise = execa(packageManager, ['run', script], { cwd });

try {
await promise;
const result = await promise;

debugLog(`Finished running script ${script}`);
debugLog(result.stdout);
debugLog(result.stderr);

return promise;
} catch (e) {
Expand Down Expand Up @@ -131,10 +137,8 @@ export async function createAddon({
}) {
let emberCliArgs = ['addon', name, '-b', blueprintPath, '--skip-npm', '--skip-git', ...args];

if (DEBUG) {
console.debug(`Running ember-cli in ${options.cwd}`);
console.debug(`\tember ${emberCliArgs.join(' ')}`);
}
debugLog(`Running ember-cli in ${options.cwd}`);
debugLog(`\tember ${emberCliArgs.join(' ')}`);

let result = await execa('ember', emberCliArgs, {
...options,
Expand Down
2 changes: 2 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"test": "pnpm vitest"
},
"devDependencies": {
"@types/debug": "^4.1.8",
"@types/fs-extra": "^9.0.13",
"@vitest/ui": "^0.18.0",
"c8": "^7.11.3",
"debug": "^4.3.4",
"ember-cli": "ember-cli/ember-cli#master",
"execa": "^6.1.0",
"fixturify": "^3.0.0",
Expand Down