Skip to content

Commit

Permalink
Merge pull request #2071 from embroider-build/no-test-entrypoint
Browse files Browse the repository at this point in the history
change blueprint to not need a synthesized test entrypoint
  • Loading branch information
ef4 authored Aug 30, 2024
2 parents d9fc688 + f008ce7 commit b059849
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 163 deletions.
5 changes: 1 addition & 4 deletions packages/core/src/app-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface RouteFiles {
}

export class AppFiles {
readonly tests: ReadonlyArray<string>;
readonly components: ReadonlyArray<string>;
readonly helpers: ReadonlyArray<string>;
readonly modifiers: ReadonlyArray<string>;
Expand All @@ -26,7 +25,6 @@ export class AppFiles {
staticAppPathsPattern: RegExp | undefined,
podModulePrefix?: string
) {
let tests: string[] = [];
let components: string[] = [];
let helpers: string[] = [];
let modifiers: string[] = [];
Expand Down Expand Up @@ -78,7 +76,7 @@ export class AppFiles {
}

if (relativePath.startsWith('tests/')) {
tests.push(relativePath);
// skip tests because they are dealt with separately
continue;
}

Expand Down Expand Up @@ -134,7 +132,6 @@ export class AppFiles {
otherAppFiles.push(relativePath);
}
}
this.tests = tests;
this.components = components;
this.helpers = helpers;
this.modifiers = modifiers;
Expand Down
32 changes: 0 additions & 32 deletions packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export class Resolver {
request = this.handleVendorStyles(request);
request = this.handleTestSupportStyles(request);
request = this.handleEntrypoint(request);
request = this.handleTestEntrypoint(request);
request = this.handleRouteEntrypoint(request);
request = this.handleRenaming(request);
request = this.handleVendor(request);
Expand Down Expand Up @@ -470,37 +469,6 @@ export class Resolver {
return logTransition('entrypoint', request, request.virtualize(resolve(pkg.root, '-embroider-entrypoint.js')));
}

private handleTestEntrypoint<R extends ModuleRequest>(request: R): R {
if (isTerminal(request)) {
return request;
}

//TODO move the extra forwardslash handling out into the vite plugin
const candidates = [
'@embroider/core/test-entrypoint',
'/@embroider/core/test-entrypoint',
'./@embroider/core/test-entrypoint',
];

if (!candidates.some(c => request.specifier === c)) {
return request;
}

const pkg = this.packageCache.ownerOfFile(request.fromFile);

if (!pkg?.isV2Ember() || !pkg.isV2App()) {
throw new Error(
`bug: found test entrypoint import from somewhere other than the top-level app engine: ${request.fromFile}`
);
}

return logTransition(
'test-entrypoint',
request,
request.virtualize(resolve(pkg.root, '-embroider-test-entrypoint.js'))
);
}

private handleRouteEntrypoint<R extends ModuleRequest>(request: R): R {
if (isTerminal(request)) {
return request;
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/virtual-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { decodeVirtualVendor, renderVendor } from './virtual-vendor';
import { decodeVirtualVendorStyles, renderVendorStyles } from './virtual-vendor-styles';

import { decodeEntrypoint, renderEntrypoint } from './virtual-entrypoint';
import { decodeTestEntrypoint, renderTestEntrypoint } from './virtual-test-entrypoint';
import { decodeRouteEntrypoint, renderRouteEntrypoint } from './virtual-route-entrypoint';

const externalESPrefix = '/@embroider/ext-es/';
Expand All @@ -34,11 +33,6 @@ export function virtualContent(filename: string, resolver: Resolver): VirtualCon
return renderEntrypoint(resolver, entrypoint);
}

let testEntrypoint = decodeTestEntrypoint(filename);
if (testEntrypoint) {
return renderTestEntrypoint(resolver, testEntrypoint);
}

let routeEntrypoint = decodeRouteEntrypoint(filename);
if (routeEntrypoint) {
return renderRouteEntrypoint(resolver, routeEntrypoint);
Expand Down
85 changes: 0 additions & 85 deletions packages/core/src/virtual-test-entrypoint.ts

This file was deleted.

9 changes: 7 additions & 2 deletions test-packages/sample-transforms/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="/@embroider/core/entrypoint" type="module"></script>
<script src="/@embroider/core/test-entrypoint" type="module"></script>
<script type="module">import "ember-testing";</script>

<script type="module">
import { start } from './test-helper';
import.meta.glob("./**/*.{js,gjs,gts}", { eager: true });
start();
</script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
10 changes: 6 additions & 4 deletions test-packages/sample-transforms/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import config from 'dummy/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import { start as qunitStart } from 'ember-qunit';

setApplication(Application.create(config.APP));
export function start() {
setApplication(Application.create(config.APP));

setup(QUnit.assert);
setup(QUnit.assert);

start();
qunitStart();
}
9 changes: 7 additions & 2 deletions tests/addon-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="/@embroider/core/test-entrypoint" type="module"></script>
<script type="module">import "ember-testing";</script>

<script type="module">
import { start } from './test-helper';
import.meta.glob("./**/*.{js,gjs,gts}", { eager: true });
start();
</script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
10 changes: 6 additions & 4 deletions tests/addon-template/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import config from 'dummy/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import { start as qunitStart } from 'ember-qunit';

setApplication(Application.create(config.APP));
export function start() {
setApplication(Application.create(config.APP));

setup(QUnit.assert);
setup(QUnit.assert);

start();
qunitStart();
}
10 changes: 8 additions & 2 deletions tests/app-template/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="/@embroider/core/test-entrypoint" type="module"></script>
<script type="module">import "ember-testing";</script>

{{content-for "body-footer"}} {{content-for "test-body-footer"}}
<script type="module">
import { start } from './test-helper';
import.meta.glob("./**/*.{js,gjs,gts}", { eager: true });
start();
</script>

{{content-for "body-footer"}}
</body>
</html>
10 changes: 6 additions & 4 deletions tests/app-template/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import config from 'app-template/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import { start as qunitStart } from 'ember-qunit';

setApplication(Application.create(config.APP));
export function start() {
setApplication(Application.create(config.APP));

setup(QUnit.assert);
setup(QUnit.assert);

start();
qunitStart();
}
12 changes: 12 additions & 0 deletions tests/fixtures/macro-sample-addon-classic/tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Application from 'dummy/app';
import config from 'dummy/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';

setApplication(Application.create(config.APP));

setup(QUnit.assert);

start();
9 changes: 7 additions & 2 deletions tests/fixtures/macro-sample-addon/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="/@embroider/core/test-entrypoint" type="module"></script>
<script type="module">import "ember-testing";</script>

<script type="module">
import { start } from './test-helper';
import.meta.glob("./**/*.{js,gjs,gts}", { eager: true });
start();
</script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
12 changes: 7 additions & 5 deletions tests/fixtures/macro-sample-addon/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import config from 'dummy/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import { start as qunitStart } from 'ember-qunit';

window.LoadedFromCustomAppBoot = true;
setApplication(Application.create(config.APP));
export function start() {
window.LoadedFromCustomAppBoot = true;
setApplication(Application.create(config.APP));

setup(QUnit.assert);
setup(QUnit.assert);

start();
qunitStart();
}
12 changes: 12 additions & 0 deletions tests/fixtures/macro-test-classic/tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Application from 'app-template/app';
import config from 'app-template/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';

setApplication(Application.create(config.APP));

setup(QUnit.assert);

start();
11 changes: 8 additions & 3 deletions tests/fixtures/macro-test/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@
<script src="{{rootURL}}apple.js"></script>
<script src="{{rootURL}}ordered.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script src="/@embroider/core/test-entrypoint" type="module"></script>
<script type="module">import "ember-testing";</script>

<script type="module">
import { start } from './test-helper';
import.meta.glob("./**/*.{js,gjs,gts}", { eager: true });
start();
</script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions tests/scenarios/macro-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ appScenarios
});

appScenarios
.map('macro-tests-classic', project => {
.map('classic-macro-tests', project => {
scenarioSetup(project);
merge(project.files, loadFromFixtureData('macro-test-classic'));
})
Expand All @@ -120,7 +120,7 @@ appScenarios
app = await scenario.prepare();
});

test(`EMBROIDER_TEST_SETUP_FORCE=classic pnpm test`, async function (assert) {
test(`EMBROIDER_TEST_SETUP_FORCE=classic pnpm ember test`, async function (assert) {
// throw_unless_parallelizable is enabled to ensure that @embroider/macros is parallelizable
let result = await app.execute(`pnpm ember test`, {
env: {
Expand Down
Loading

0 comments on commit b059849

Please sign in to comment.