mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
benchmark: throw on invalid type in fs and webstorage
The default branch of the type switch constructed an Error without throwing it, so an unknown type silently benchmarked an undefined path instead of failing. Assisted-by: a closed-source coding agent Signed-off-by: Minho Yoo <13810291+irontaek@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/66647 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
1 parent
4b810e2c5e
commit
b6567ea812
21 files changed
+21
-21
No files matched your search
@@ -48,7 +48,7 @@ function main({ n, type, method }) {
|
||||
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
if (method === 'access') {
|
||||
|
||||
@@ -36,6 +36,6 @@ function main({ n, type }) {
|
||||
bench.end(n);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,6 @@ function main({ n, type, method }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ function main({ n, type }) {
|
||||
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -28,7 +28,7 @@ function main({ n, type }) {
|
||||
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
const fds = files.map((x) => {
|
||||
|
||||
@@ -24,7 +24,7 @@ function main({ n, type }) {
|
||||
fd = 1 << 30;
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -45,6 +45,6 @@ function main({ n, type }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ function main({ n, type, recursive }) {
|
||||
files = new Array(n).fill(__dirname);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -27,7 +27,7 @@ function main({ n, type }) {
|
||||
prefix = tmpdir.resolve('non-existent', 'foo', 'bar');
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -33,7 +33,7 @@ function main({ n, type }) {
|
||||
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
runBench({ n, path });
|
||||
|
||||
@@ -25,7 +25,7 @@ function main({ n, type }) {
|
||||
files = [tmpdir.resolve(`.non-existing-file-${Date.now()}`)];
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -38,7 +38,7 @@ function main({ n, type }) {
|
||||
fd = 1 << 30;
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
const buffer = Buffer.alloc(bufferSize);
|
||||
|
||||
@@ -49,6 +49,6 @@ function main({ n, type }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,6 @@ function main({ n, type }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,6 @@ function main({ n, type }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,6 @@ function main({ n, type, func }) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ function main({ n, type }) {
|
||||
files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`));
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -24,7 +24,7 @@ function main({ n, type }) {
|
||||
fd = 1 << 30;
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
@@ -70,6 +70,6 @@ function main({ n, type }) {
|
||||
bench.end(n);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,6 @@ function main({ n, type }) {
|
||||
bench.end(n);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,6 @@ function main({ n, type }) {
|
||||
bench.end(n);
|
||||
break;
|
||||
default:
|
||||
new Error('Invalid type');
|
||||
throw new Error('Invalid type');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user