Skip to content

Commit

Permalink
Make tests run on Node 12, fix watcher cleanup issue (#2982)
Browse files Browse the repository at this point in the history
* Make tests run on Node 12, fix watcher cleanup issue

* Just do not run leak test on Node 12
  • Loading branch information
lukastaegert committed Jul 4, 2019
1 parent 2896755 commit ef7486d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
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)
);
}
};

0 comments on commit ef7486d

Please sign in to comment.