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

Ensure lintTree results cannot clobber tests. #7036

Merged
merged 1 commit into from May 11, 2017

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented May 10, 2017

The prior logic resulted in the result of lintTree being after the actual processed tests/ tree. When those trees were then passed to MergeTrees the lintTree result would clobber the normal processed tests/ tree. In general, when a linter is actually emitting linting tests, this is fine because the files that it emits are not the same names as the original (e.g. tests/test-helper.js becomes tests/test-helper.lint-test.js), but when the lintTree implementation does not emit different names than the input tree the lintTree versions "win".

In Ember CLI < 2.13, this setup still worked properly because we would fully process the result of lintTree through the consuming applications JS processor pipeline (e.g. babel). This sounds neat but actually means that we were transpiling all of tests/ twice.

In Ember CLI 2.13 and above, we only process the result of lintTree for modules (not a full "transpile down to ES5"). This means that any babel processing that would have been done for tests/ normally is thrown away when the transpiled versions are clobbered by the untranspiled lintTree.

This change corrects the ordering of trees, so that the correctly proccessed tests/ tree "wins" when the lintTree tree emits files with the same names.

@lukemelia
Copy link
Contributor

Nice work, @rwjblue! Thanks for tracking this down!


app.project.addons.push({
lintTree(type, tree) {
return stew.map(tree, function(string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (along with a few other linting errors).

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds reasonable 👍

lintTree(type, tree) {
return stew.map(tree, string => string.toUpperCase());
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this doing? could use a short comment explaining it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will do.

The prior logic resulted in the result of `lintTree` being
**after** the actual processed `tests/` tree. When those trees
were then passed to `MergeTrees` the `lintTree` result would
clobber the normal processed `tests/` tree. In general, when
a linter is actually emitting linting tests, this is fine
because the files that it emits are not the same names as the
original (e.g. `tests/test-helper.js` becomes
`tests/test-helper.lint-test.js`), but when the `lintTree`
implementation does not emit different names than the input tree
the `lintTree` versions "win".

In Ember CLI < 2.13, this setup still worked properly because we
would fully process the result of `lintTree` through the consuming
applications JS processor pipeline (e.g. babel). This _sounds_ neat
but actually means that we were transpiling all of `tests/` twice.

In Ember CLI 2.13 and above, we only process the result of `lintTree`
for modules (not a full "transpile down to ES5"). This means that
any babel processing that would have been done for `tests/` normally
is thrown away when the transpiled versions are clobbered by the
untranspiled `lintTree`.

This change corrects the ordering of trees, so that the correctly
proccessed `tests/` tree "wins" when the `lintTree` tree emits files
with the same names.
@rwjblue rwjblue force-pushed the fix-lint-clobbering-tests branch from 0d4b4ec to 7ac7d9f Compare May 11, 2017 13:54
@rwjblue
Copy link
Member Author

rwjblue commented May 11, 2017

Updated with more comments around the test adding a fake lintTree (for observing side effects). Also confirmed that without the changes made to lib/broccoli/ember-app.js the test fails in the same way as was reported (just to make sure the test was emulating the right thing).

@rwjblue
Copy link
Member Author

rwjblue commented May 11, 2017

@homu r+

@homu
Copy link
Contributor

homu commented May 11, 2017

📌 Commit 7ac7d9f has been approved by rwjblue

homu added a commit that referenced this pull request May 11, 2017
Ensure `lintTree` results cannot clobber tests.

The prior logic resulted in the result of `lintTree` being **after** the actual processed `tests/` tree. When those trees were then passed to `MergeTrees` the `lintTree` result would clobber the normal processed `tests/` tree. In general, when a linter is actually emitting linting tests, this is fine because the files that it emits are not the same names as the original (e.g. `tests/test-helper.js` becomes `tests/test-helper.lint-test.js`), but when the `lintTree` implementation does not emit different names than the input tree the `lintTree` versions "win".

In Ember CLI < 2.13, this setup still worked properly because we would fully process the result of `lintTree` through the consuming applications JS processor pipeline (e.g. babel). This _sounds_ neat but actually means that we were transpiling all of `tests/` twice.

In Ember CLI 2.13 and above, we only process the result of `lintTree` for modules (not a full "transpile down to ES5"). This means that any babel processing that would have been done for `tests/` normally is thrown away when the transpiled versions are clobbered by the untranspiled `lintTree`.

This change corrects the ordering of trees, so that the correctly proccessed `tests/` tree "wins" when the `lintTree` tree emits files with the same names.
@homu
Copy link
Contributor

homu commented May 11, 2017

⌛ Testing commit 7ac7d9f with merge 35eebe1...

@homu
Copy link
Contributor

homu commented May 11, 2017

☀️ Test successful - status

@homu homu merged commit 7ac7d9f into ember-cli:release May 11, 2017
@stefanpenner stefanpenner deleted the fix-lint-clobbering-tests branch May 11, 2017 15:01
@Turbo87 Turbo87 added the bug label May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants