Skip to content

Commit ef7486d

Browse files
authored
Make tests run on Node 12, fix watcher cleanup issue (#2982)
* Make tests run on Node 12, fix watcher cleanup issue * Just do not run leak test on Node 12
1 parent 2896755 commit ef7486d

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

.circleci/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ unit_tests: &unit_tests
99
name: Run unit tests.
1010
command: npm run ci:test
1111

12+
unit_tests_12: &unit_tests_12
13+
steps:
14+
- checkout
15+
- restore_cache:
16+
key: dependency-cache-{{ checksum "package-lock.json" }}
17+
- run:
18+
name: Run unit tests.
19+
command: npm run ci:test_12
20+
1221
jobs:
1322
analysis:
1423
docker:
@@ -42,6 +51,10 @@ jobs:
4251
docker:
4352
- image: rollupcabal/circleci-node-v10:latest
4453
<<: *unit_tests
54+
node-v12-latest:
55+
docker:
56+
- image: rollupcabal/circleci-node-v12:latest
57+
<<: *unit_tests_12
4558

4659
workflows:
4760
version: 2
@@ -69,3 +82,9 @@ workflows:
6982
filters:
7083
tags:
7184
only: /.*/
85+
- node-v12-latest:
86+
requires:
87+
- analysis
88+
filters:
89+
tags:
90+
only: /.*/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ci:coverage": "npm run test:coverage",
1717
"ci:lint": "npm run lint:nofix && npm run security",
1818
"ci:test": "npm run build:test && npm run build:bootstrap && npm run test:all",
19+
"ci:test_12": "npm run build:test && npm run build:bootstrap && npm run test:only && npm run test:typescript",
1920
"lint": "npm run lint:ts -- --fix && npm run lint:js -- --fix && npm run lint:markdown",
2021
"lint:nofix": "npm run lint:ts && npm run lint:js && npm run lint:markdown",
2122
"lint:ts": "tslint --project .",

src/watch/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,26 @@ export class Task {
211211
return rollup(options)
212212
.then(result => {
213213
if (this.closed) return undefined as any;
214-
214+
const previouslyWatched = this.watched;
215215
const watched = (this.watched = new Set());
216216

217217
this.cache = result.cache;
218218
this.watchFiles = result.watchFiles;
219-
(this.cache.modules as ModuleJSON[]).forEach(module => {
219+
for (const module of this.cache.modules as ModuleJSON[]) {
220220
if (module.transformDependencies) {
221221
module.transformDependencies.forEach(depId => {
222222
watched.add(depId);
223223
this.watchFile(depId, true);
224224
});
225225
}
226-
});
227-
this.watchFiles.forEach(id => {
226+
}
227+
for (const id of this.watchFiles) {
228228
watched.add(id);
229229
this.watchFile(id);
230-
});
231-
this.watched.forEach(id => {
230+
}
231+
for (const id of previouslyWatched) {
232232
if (!watched.has(id)) deleteTask(id, this, this.chokidarOptionsHash);
233-
});
233+
}
234234

235235
return Promise.all(this.outputs.map(output => result.write(output))).then(() => result);
236236
})

test/function/samples/catch-dynamic-import-failure/_config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = {
1010
return exports.then(result => {
1111
assert.strictEqual(result[0].message, 'exists-named');
1212
assert.strictEqual(result[1].message, 'exists-default');
13-
assert.strictEqual(result[2].message, "Cannot find module 'does-not-exist'");
13+
const expectedError = "Cannot find module 'does-not-exist'";
14+
assert.strictEqual(result[2].message.slice(0, expectedError.length), expectedError);
1415
});
1516
}
1617
};

test/function/samples/dynamic-import-expression/_config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module.exports = {
2424
]
2525
},
2626
exports(exports) {
27-
return exports.catch(err => assert.strictEqual(err.message, "Cannot find module 'x/y'"));
27+
const expectedError = "Cannot find module 'x/y'";
28+
return exports.catch(err =>
29+
assert.strictEqual(err.message.slice(0, expectedError.length), expectedError)
30+
);
2831
}
2932
};

test/function/samples/dynamic-import-rewriting/_config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module.exports = {
1313
]
1414
},
1515
exports(exports) {
16-
return exports.promise.catch(err => assert.equal(err.message, "Cannot find module 'asdf'"));
16+
const expectedError = "Cannot find module 'asdf'";
17+
return exports.promise.catch(err =>
18+
assert.strictEqual(err.message.slice(0, expectedError.length), expectedError)
19+
);
1720
}
1821
};

0 commit comments

Comments
 (0)