1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Description: fix this test to pass on nodejs 18.13 and 18.19
Author: Jérémy Lal <kapouer@melix.org>
Last-Update: 2024-04-13
Forwarded: https://github.com/zertosh/v8-compile-cache/pull/49
Origin: https://github.com/zertosh/v8-compile-cache/commit/de822a607c9dbe7cfc826a44c67fc5f82b03c9ca
--- a/test/NativeCompileCache-test.js
+++ b/test/NativeCompileCache-test.js
@@ -85,12 +85,14 @@
tap.test('deletes previously cached code when the cache is an invalid file', t => {
fakeCacheStore.has = () => true;
fakeCacheStore.get = () => Buffer.from('an invalid cache');
- let deleteWasCalledWith = null;
- fakeCacheStore.delete = arg => { deleteWasCalledWith = arg; };
+ let wasCalledWith = null;
+ fakeCacheStore.set = arg => { wasCalledWith = arg; };
+ // older v8 still calls delete, though
+ fakeCacheStore.delete = arg => { wasCalledWith = arg; };
const fn3 = require('./fixtures/file-3');
- t.equal(deleteWasCalledWith, require.resolve('./fixtures/file-3'));
+ t.equal(wasCalledWith, require.resolve('./fixtures/file-3'));
t.equal(fn3(), 3);
t.end();
--- a/test/FileSystemBlobStore-mock.js
+++ b/test/FileSystemBlobStore-mock.js
@@ -20,7 +20,14 @@
}
set(key, invalidationKey, buffer) {
+ const entry = this._cachedFiles.find(
+ file => file.key === key && file.invalidationKey === invalidationKey
+ );
+ if (entry == null) {
this._cachedFiles.push({key, invalidationKey, buffer});
+ } else {
+ entry.buffer = buffer;
+ }
return buffer;
}
|