Quantcast
Viewing all articles
Browse latest Browse all 4826

Testing an addon's broccoli trees — issue with broccoli caches

@lennyburdette wrote:

I’m trying to fix a bug in ember-intl related to engines, and I’d like to write a test that exercises the whole build process. I tried ember-cli-addon-tests, but I had a hard time setting up an engine in the test, and it was crazy slow so I switched tactics.

The broccoli-test-helper package seemed more promising and I have a single working test. However, any subsequent tests are failing.

Here’s a simplified version of my test:

it('does the right thing', co.wrap(function*() {
  const input = yield createTempDir();
  input.write(fixturesWithAnEmberAppAndAnEngine);

  // symlink the addon's node_modules next to the fixture app so that EmberApp can
  // find its dependencies. this is much faster than copying it or actually running `npm install`
  // like ember-cli-addon-tests does.
  fs.symlinkSync('node_modules', input.path() + '/node_modules');

  // move the cwd to the Ember app so that new EmberApp() does the right thing
  process.chdir(input.path() + '/application'); 

  const output = createBuilder(new EmberApp().toTree());
  yield output.build();

  expect(output.read()).to.equal(expectedResults);

  yield input.dispose();
  yield output.dispose();
});

The second test fails during the broccoli build with this error:

ENOENT: no such file or directory, scandir '/var/folders/d6/rsf2l61x0x59gy2hsk23y04h0001sx/T/broccoli-33436WNPsAlNGVfbg/out-016-broccoli_merge_trees_addon_tree_for_ember_getowner_polyfill/'
  at BroccoliMergeTrees (Addon#treeFor (ember-intl - vendor))
The rest of the stack trace is here:
-~- created here: -~-
    at BroccoliMergeTrees.Plugin (/Users/lenny/Documents/GitHub/ember-intl/node_modules/broccoli-plugin/index.js:7:31)
    at new BroccoliMergeTrees (/Users/lenny/Documents/GitHub/ember-intl/node_modules/broccoli-merge-trees/index.js:16:10)
    at Function.BroccoliMergeTrees [as _upstreamMergeTrees] (/Users/lenny/Documents/GitHub/ember-intl/node_modules/broccoli-merge-trees/index.js:10:53)
    at mergeTrees (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/merge-trees.js:85:33)
    at Class.treeFor (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/models/addon.js:548:30)
    at project.addons.reduce (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:630:25)
    at Array.reduce (<anonymous>)
    at EmberApp.addonTreesFor (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:628:32)
    at EmberApp._processedVendorTree (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1115:24)
    at EmberApp._processedExternalTree (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1143:25)
    at EmberApp.appAndDependencies (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1263:25)
    at EmberApp.javascript (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1396:30)
    at EmberApp.toArray (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1821:12)
    at EmberApp.toTree (/Users/lenny/Documents/GitHub/ember-intl/node_modules/ember-cli/lib/broccoli/ember-app.js:1845:32)
    at Context.<anonymous> (/Users/lenny/Documents/GitHub/ember-intl/tests-node/acceptance/engines-test.js:46:53)
    at Generator.next (<anonymous>)
    at onFulfilled (/Users/lenny/Documents/GitHub/ember-intl/node_modules/co/index.js:65:19)
    at <anonymous>
-~- (end) -~-

The directory referenced (.../T/broccoli-33436WNPsAlNGVfbg) is in fact the tmp directory from the previous test, so I’d love a way to clear the cache between tests. Is this possible? Or is there a better way to write a test like this? Image may be NSFW.
Clik here to view.
:pray:

Things I've tried
  • Symlinking node_modules once instead of once per test
  • DEBUG=broccoli* — the only difference in the log output is the broccoli temp directory

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles