From a65aa56df5b008e6e4bc5b87988ea5fada774ea6 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Wed, 25 Aug 2021 12:24:38 -0700 Subject: [PATCH] Moving cache busting tests to seperate job --- tests/scenarios/macro-test.ts | 64 ++++++++++++++++++++++------------- tests/scenarios/scenarios.ts | 8 +++++ 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/tests/scenarios/macro-test.ts b/tests/scenarios/macro-test.ts index bfd398fe5..8f7f539f3 100644 --- a/tests/scenarios/macro-test.ts +++ b/tests/scenarios/macro-test.ts @@ -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'; @@ -18,31 +18,35 @@ 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) { @@ -50,7 +54,6 @@ appScenarios hooks.before(async () => { app = await scenario.prepare(); - updateLodashVersion(app, '4.0.0'); }); test(`yarn test`, async function (assert) { @@ -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`); diff --git a/tests/scenarios/scenarios.ts b/tests/scenarios/scenarios.ts index a13694078..441185ae7 100644 --- a/tests/scenarios/scenarios.ts +++ b/tests/scenarios/scenarios.ts @@ -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'))) +);