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

Make tests run on Node 12, fix watcher cleanup issue #2982

Merged
merged 2 commits into from Jul 4, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions .circleci/config.yml
Expand Up @@ -9,6 +9,15 @@ unit_tests: &unit_tests
name: Run unit tests.
command: npm run ci:test

unit_tests_12: &unit_tests_12
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Run unit tests.
command: npm run ci:test_12

jobs:
analysis:
docker:
Expand Down Expand Up @@ -42,6 +51,10 @@ jobs:
docker:
- image: rollupcabal/circleci-node-v10:latest
<<: *unit_tests
node-v12-latest:
docker:
- image: rollupcabal/circleci-node-v12:latest
<<: *unit_tests_12

workflows:
version: 2
Expand Down Expand Up @@ -69,3 +82,9 @@ workflows:
filters:
tags:
only: /.*/
- node-v12-latest:
requires:
- analysis
filters:
tags:
only: /.*/
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -16,6 +16,7 @@
"ci:coverage": "npm run test:coverage",
"ci:lint": "npm run lint:nofix && npm run security",
"ci:test": "npm run build:test && npm run build:bootstrap && npm run test:all",
"ci:test_12": "npm run build:test && npm run build:bootstrap && npm run test:only && npm run test:typescript",
"lint": "npm run lint:ts -- --fix && npm run lint:js -- --fix && npm run lint:markdown",
"lint:nofix": "npm run lint:ts && npm run lint:js && npm run lint:markdown",
"lint:ts": "tslint --project .",
Expand Down
14 changes: 7 additions & 7 deletions src/watch/index.ts
Expand Up @@ -211,26 +211,26 @@ export class Task {
return rollup(options)
.then(result => {
if (this.closed) return undefined as any;

const previouslyWatched = this.watched;
const watched = (this.watched = new Set());

this.cache = result.cache;
this.watchFiles = result.watchFiles;
(this.cache.modules as ModuleJSON[]).forEach(module => {
for (const module of this.cache.modules as ModuleJSON[]) {
if (module.transformDependencies) {
module.transformDependencies.forEach(depId => {
watched.add(depId);
this.watchFile(depId, true);
});
}
});
this.watchFiles.forEach(id => {
}
for (const id of this.watchFiles) {
watched.add(id);
this.watchFile(id);
});
this.watched.forEach(id => {
}
for (const id of previouslyWatched) {
if (!watched.has(id)) deleteTask(id, this, this.chokidarOptionsHash);
});
}

return Promise.all(this.outputs.map(output => result.write(output))).then(() => result);
})
Expand Down
Expand Up @@ -10,7 +10,8 @@ module.exports = {
return exports.then(result => {
assert.strictEqual(result[0].message, 'exists-named');
assert.strictEqual(result[1].message, 'exists-default');
assert.strictEqual(result[2].message, "Cannot find module 'does-not-exist'");
const expectedError = "Cannot find module 'does-not-exist'";
assert.strictEqual(result[2].message.slice(0, expectedError.length), expectedError);
});
}
};
5 changes: 4 additions & 1 deletion test/function/samples/dynamic-import-expression/_config.js
Expand Up @@ -24,6 +24,9 @@ module.exports = {
]
},
exports(exports) {
return exports.catch(err => assert.strictEqual(err.message, "Cannot find module 'x/y'"));
const expectedError = "Cannot find module 'x/y'";
return exports.catch(err =>
assert.strictEqual(err.message.slice(0, expectedError.length), expectedError)
);
}
};
5 changes: 4 additions & 1 deletion test/function/samples/dynamic-import-rewriting/_config.js
Expand Up @@ -13,6 +13,9 @@ module.exports = {
]
},
exports(exports) {
return exports.promise.catch(err => assert.equal(err.message, "Cannot find module 'asdf'"));
const expectedError = "Cannot find module 'asdf'";
return exports.promise.catch(err =>
assert.strictEqual(err.message.slice(0, expectedError.length), expectedError)
);
}
};