Skip to content
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
24 changes: 12 additions & 12 deletions packages/core/__tests__/cli/build-watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

project.write(INPUT_SFC, code);

let watch = project.buildWatch({ reject: true });
let watch = project.buildDeclarationWatch({ reject: true });
let output = await watch.awaitOutput('Watching for file changes.');
await watch.terminate();

Expand Down Expand Up @@ -107,7 +107,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

project.write(INPUT_SFC, code);

let watch = project.buildWatch({ reject: false });
let watch = project.buildDeclarationWatch({ reject: false });
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -146,7 +146,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

project.write(INPUT_SFC, code);

let watch = project.buildWatch();
let watch = project.buildDeclarationWatch();
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -187,7 +187,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

project.write(INPUT_SFC, code);

let watch = project.buildWatch({ reject: true });
let watch = project.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -230,7 +230,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

project.write(INPUT_SFC, code);

let watch = project.buildWatch({ reject: true });
let watch = project.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -329,7 +329,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
});

test('passes when all projects are valid', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand All @@ -340,7 +340,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
describe('reports on errors introduced and cleared during the watch', () => {
describe('for template syntax errors', () => {
test('in the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -379,7 +379,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
});

test('in a project with references referenced directly by the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -417,7 +417,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
});

test('in a project transitively referenced by the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -455,7 +455,7 @@ describe.skip('CLI: watched build mode typechecking', () => {

describe('for template type errors', () => {
test('in the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -488,7 +488,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
});

test('in a project with references referenced directly by the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -521,7 +521,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
});

test('in a project transitively referenced by the root', async () => {
let watch = projects.root.buildWatch({ reject: true });
let watch = projects.root.buildDeclarationWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down
34 changes: 17 additions & 17 deletions packages/core/__tests__/cli/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ describe('CLI: single-pass build mode typechecking', () => {

project.write(INPUT_SFC, code);

let checkResult = await project.build({ reject: false });
let checkResult = await project.buildDeclaration({ reject: false });

expect(checkResult.exitCode).toBe(0);
expect(checkResult.stdout).toEqual('');
expect(checkResult.stderr).toEqual('');

// This tests that the `--emitDeclarationOnly` flag within project.build is working.
// This tests that the `--emitDeclarationOnly` flag within project.buildDeclaration is working.
expect(existsSync(project.filePath('dist/index.gts.js'))).toBe(false);
});

Expand All @@ -79,7 +79,7 @@ describe('CLI: single-pass build mode typechecking', () => {

project.write(INPUT_SFC, code);

let checkResult = await project.build({ reject: false });
let checkResult = await project.buildDeclaration({ reject: false });

expect(checkResult.exitCode).toBe(1);
expect(checkResult.stdout).toEqual('');
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('CLI: single-pass build mode typechecking', () => {

project.write(INPUT_SFC, code);

let checkResult = await project.build({ reject: false });
let checkResult = await project.buildDeclaration({ reject: false });

expect(checkResult.exitCode).toBe(1);
expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -1099,11 +1099,11 @@ describe.skip('CLI: --build --clean', () => {

project.write(INPUT_SFC, code);

let buildResult = await project.build();
let buildResult = await project.buildDeclaration();
expect(buildResult.exitCode).toBe(0);
expect(existsSync(project.filePath(INDEX_D_TS))).toBe(true);

let buildCleanResult = await project.build({ flags: ['--clean'] });
let buildCleanResult = await project.buildDeclaration({ flags: ['--clean'] });
expect(buildCleanResult.exitCode).toBe(0);
expect(existsSync(project.filePath(INDEX_D_TS))).toBe(false);
});
Expand Down Expand Up @@ -1193,13 +1193,13 @@ describe.skip('CLI: --build --force', () => {

project.write(INPUT_SFC, code);

let buildResult = await project.build();
let buildResult = await project.buildDeclaration();
expect(buildResult.exitCode).toBe(0);
let indexDTs = project.filePath(INDEX_D_TS);
expect(existsSync(indexDTs)).toBe(true);
let firstStat = statSync(indexDTs);

let buildCleanResult = await project.build({ flags: ['--force'] });
let buildCleanResult = await project.buildDeclaration({ flags: ['--force'] });
expect(buildCleanResult.exitCode).toBe(0);
let exists = existsSync(indexDTs);
expect(exists).toBe(true);
Expand Down Expand Up @@ -1309,7 +1309,7 @@ describe.skip('CLI: --build --dry', () => {
});

test('when no build has occurred', async () => {
let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
Expand All @@ -1319,11 +1319,11 @@ describe.skip('CLI: --build --dry', () => {

describe('when the project has been built', () => {
beforeEach(async () => {
await project.build();
await project.buildDeclaration();
});

test('when there are no changes', async () => {
let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`Project '${project.filePath('tsconfig.json')}' is up to date`,
Expand Down Expand Up @@ -1352,7 +1352,7 @@ describe.skip('CLI: --build --dry', () => {

project.write(INPUT_SFC, code);

let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
Expand Down Expand Up @@ -1393,7 +1393,7 @@ describe.skip('CLI: --build --dry', () => {
});

test('when no build has occurred', async () => {
let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
Expand All @@ -1403,11 +1403,11 @@ describe.skip('CLI: --build --dry', () => {

describe('when the project has been built', () => {
beforeEach(async () => {
await project.build();
await project.buildDeclaration();
});

test('when there are no changes', async () => {
let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`Project '${project.filePath('tsconfig.json')}' is up to date`,
Expand All @@ -1431,7 +1431,7 @@ describe.skip('CLI: --build --dry', () => {
`;
project.write(INPUT_SCRIPT, backingClass);

let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
Expand All @@ -1447,7 +1447,7 @@ describe.skip('CLI: --build --dry', () => {

project.write(INPUT_TEMPLATE, template);

let buildResult = await project.build({ flags: ['--dry'] });
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
expect(buildResult.exitCode).toBe(0);
expect(stripAnsi(buildResult.stdout)).toMatch(
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/__tests__/cli/custom-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe.skip('CLI: custom extensions', () => {
project.setGlintConfig({ environment: 'ember-template-imports' });
project.write('index.gts', code);

let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -73,7 +73,7 @@ describe.skip('CLI: custom extensions', () => {
});

test('adding a missing module', async () => {
let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

expect(output).toMatch('Found 1 error.');
Expand All @@ -90,7 +90,7 @@ describe.skip('CLI: custom extensions', () => {
test('changing an imported module', async () => {
project.write('other.gjs', 'export const foo = 123;');

let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

expect(output).toMatch('Found 0 errors.');
Expand All @@ -107,7 +107,7 @@ describe.skip('CLI: custom extensions', () => {
test('removing an imported module', async () => {
project.write('other.gjs', 'export const foo = 123;');

let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

expect(output).toMatch('Found 0 errors.');
Expand Down
16 changes: 8 additions & 8 deletions packages/core/__tests__/cli/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch({ reject: true });
let watch = project.checkWatch({ reject: true });
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch();
let watch = project.checkWatch();
let output = await watch.awaitOutput('Watching for file changes.');

await watch.terminate();
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch({ reject: true });
let watch = project.checkWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('CLI: watched typechecking', () => {

project.write('my-component.ts', script);

let watch = project.watch({ reject: true });
let watch = project.checkWatch({ reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch({ reject: true });
let watch = project.checkWatch({ reject: true });
let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');

Expand Down Expand Up @@ -273,7 +273,7 @@ describe('CLI: watched typechecking', () => {
project.write('my-component.ts', script);
project.write('my-component.hbs', template);

let watch = project.watch();
let watch = project.checkWatch();

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('CLI: watched typechecking', () => {

project.write('index.gts', code);

let watch = project.watch({ flags: ['--preserveWatchOutput'], reject: true });
let watch = project.checkWatch({ flags: ['--preserveWatchOutput'], reject: true });

let output = await watch.awaitOutput('Watching for file changes.');
expect(output).toMatch('Found 0 errors.');
Expand Down
11 changes: 7 additions & 4 deletions test-packages/test-utils/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,15 @@ export class Project {
});
}

public watch(options: Options & { flags?: string[] } = {}): Watch {
public checkWatch(options: Options & { flags?: string[] } = {}): Watch {
let flags = ['--watch', ...(options.flags ?? [])];
return new Watch(this.check({ ...options, flags, reject: false }));
}

public build(options: Options & { flags?: string[] } = {}, debug = false): ExecaChildProcess {
public buildDeclaration(
options: Options & { flags?: string[] } = {},
debug = false,
): ExecaChildProcess {
let flags = ['--build', '--emitDeclarationOnly', '--pretty', ...(options.flags ?? [])];
return execaNode(require.resolve('@glint/core/bin/glint'), flags, {
cwd: this.rootDir,
Expand All @@ -320,9 +323,9 @@ export class Project {
});
}

public buildWatch(options: Options & { flags?: string[] } = {}): Watch {
public buildDeclarationWatch(options: Options & { flags?: string[] } = {}): Watch {
let flags = ['--watch', ...(options.flags ?? [])];
return new Watch(this.build({ ...options, flags, reject: false }));
return new Watch(this.buildDeclaration({ ...options, flags, reject: false }));
}
}

Expand Down