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

Moving cache busting tests to separate CI job #938

Merged
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
64 changes: 41 additions & 23 deletions tests/scenarios/macro-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appScenarios } from './scenarios';
import { appScenarios, appReleaseScenario } from './scenarios';
import { PreparedApp, Project } from 'scenario-tester';
import QUnit from 'qunit';
import merge from 'lodash/merge';
Expand All @@ -18,39 +18,42 @@ function updateLodashVersion(app: PreparedApp, version: string) {
fs.writeJsonSync(join(app.dir, 'node_modules', 'lodash', 'package.json'), pkgJsonLodash);
}

appScenarios
.map('macro-tests', project => {
let macroSampleAddon = Project.fromDir(dirname(require.resolve('../addon-template/package.json')), {
linkDeps: true,
});
let funkySampleAddon = Project.fromDir(dirname(require.resolve('../addon-template/package.json')), {
linkDeps: true,
});
function scenarioSetup(project: Project) {
let macroSampleAddon = Project.fromDir(dirname(require.resolve('../addon-template/package.json')), {
linkDeps: true,
});
let funkySampleAddon = Project.fromDir(dirname(require.resolve('../addon-template/package.json')), {
linkDeps: true,
});

macroSampleAddon.pkg.name = 'macro-sample-addon';
funkySampleAddon.pkg.name = '@embroider/funky-sample-addon';
macroSampleAddon.pkg.name = 'macro-sample-addon';
funkySampleAddon.pkg.name = '@embroider/funky-sample-addon';

merge(macroSampleAddon.files, loadFromFixtureData('macro-sample-addon'));
merge(funkySampleAddon.files, loadFromFixtureData('funky-sample-addon'));
merge(project.files, loadFromFixtureData('macro-test'));
merge(macroSampleAddon.files, loadFromFixtureData('macro-sample-addon'));
merge(funkySampleAddon.files, loadFromFixtureData('funky-sample-addon'));
merge(project.files, loadFromFixtureData('macro-test'));

funkySampleAddon.linkDependency('broccoli-merge-trees', { baseDir: __dirname });
funkySampleAddon.linkDependency('broccoli-funnel', { baseDir: __dirname });
funkySampleAddon.linkDependency('@embroider/macros', { baseDir: __dirname });
macroSampleAddon.linkDependency('@embroider/macros', { baseDir: __dirname });
project.linkDevDependency('@embroider/macros', { baseDir: __dirname });
project.linkDevDependency('lodash', { baseDir: __dirname });
funkySampleAddon.linkDependency('broccoli-merge-trees', { baseDir: __dirname });
funkySampleAddon.linkDependency('broccoli-funnel', { baseDir: __dirname });
funkySampleAddon.linkDependency('@embroider/macros', { baseDir: __dirname });
macroSampleAddon.linkDependency('@embroider/macros', { baseDir: __dirname });
project.linkDevDependency('@embroider/macros', { baseDir: __dirname });
project.linkDevDependency('lodash', { baseDir: __dirname });

project.addDevDependency(macroSampleAddon);
project.addDevDependency(funkySampleAddon);
project.addDevDependency(macroSampleAddon);
project.addDevDependency(funkySampleAddon);
}

appScenarios
.map('macro-tests', project => {
scenarioSetup(project);
})
.forEachScenario(scenario => {
Qmodule(scenario.name, function (hooks) {
let app: PreparedApp;

hooks.before(async () => {
app = await scenario.prepare();
updateLodashVersion(app, '4.0.0');
});

test(`yarn test`, async function (assert) {
Expand All @@ -68,6 +71,21 @@ appScenarios
let result = await app.execute(`cross-env THROW_UNLESS_PARALLELIZABLE=1 CLASSIC=true yarn test`);
assert.equal(result.exitCode, 0, result.output);
});
});
});

appReleaseScenario
.map('macro-babel-cache-busting', project => {
scenarioSetup(project);
})
.forEachScenario(scenario => {
Qmodule(scenario.name, function (hooks) {
let app: PreparedApp;

hooks.before(async () => {
app = await scenario.prepare();
updateLodashVersion(app, '4.0.0');
});

test(`@embroider/macros babel caching plugin works`, async function (assert) {
let lodashFourRun = await app.execute(`yarn test`);
Expand Down
8 changes: 8 additions & 0 deletions tests/scenarios/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ export function supportMatrix(scenarios: Scenarios) {
});
}

export function onlyRunRelease(scenarios: Scenarios) {
return scenarios.expand({ release });
}

export const appScenarios = supportMatrix(Scenarios.fromDir(dirname(require.resolve('../app-template/package.json'))));

export const appReleaseScenario = onlyRunRelease(
Scenarios.fromDir(dirname(require.resolve('../app-template/package.json')))
);