Skip to content

Commit 043a590

Browse files
authored
fix(NODE-6357): strip version/branch/tag from test name (#19)
1 parent 9567aa3 commit 043a590

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

packages/bson-bench/src/suite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ export class Suite {
4343
(e: Error) => e
4444
);
4545
if (result instanceof Error) {
46-
console.log(`\t${task.taskName} ✗`);
46+
console.log(`\t${task.testName} ✗`);
4747
this._errors.push({ task, error: result });
4848
} else {
49-
console.log(`\t${task.taskName} ✓`);
49+
console.log(`\t${task.testName} ✓`);
5050
this._results.push(result);
5151
}
5252
}

packages/bson-bench/src/task.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class Task {
1919
result: BenchmarkResult | undefined;
2020
benchmark: BenchmarkSpecification;
2121
taskName: string;
22+
testName: string;
2223
/** @internal */
2324
children: ChildProcess[];
2425
/** @internal */
@@ -33,6 +34,8 @@ export class Task {
3334
this.taskName = `${path.basename(this.benchmark.documentPath, 'json')}_${
3435
this.benchmark.operation
3536
}_${this.benchmark.library}`;
37+
38+
this.testName = this.taskName.substring(0, this.taskName.search(/#|@/));
3639
}
3740

3841
/**
@@ -111,7 +114,7 @@ export class Task {
111114

112115
const perfSendResults: PerfSendResult = {
113116
info: {
114-
test_name: this.taskName,
117+
test_name: this.testName,
115118
args: {
116119
warmup: this.benchmark.warmup,
117120
iterations: this.benchmark.iterations,

packages/bson-bench/test/unit/task.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ describe('Task', function () {
4242
context('#run()', function () {
4343
for (const test of testTable) {
4444
context(`${test.operation} with library specifier: ${test.library}`, function () {
45+
let task;
46+
47+
beforeEach(function () {
48+
task = new Task(test);
49+
});
50+
4551
it('completes successfully', async function () {
4652
if (
4753
Number(process.versions.node.split('.')[0]) >= 20 &&
@@ -50,14 +56,18 @@ describe('Task', function () {
5056
console.log('Skipping installing bson-ext via git tag on Node 20');
5157
this.skip();
5258
}
53-
const task = new Task(test);
5459

5560
await task.run();
5661
for (const child of task.children) {
5762
expect(child.exitCode).to.not.be.null;
5863
expect(child.exitCode).to.equal(0);
5964
}
6065
});
66+
67+
it('strips the tag or commit from the test name', function () {
68+
expect(task.testName).to.not.include(test.library);
69+
expect(task.testName).to.match(/bson|bson-ext/);
70+
});
6171
});
6272
}
6373

@@ -138,7 +148,7 @@ describe('Task', function () {
138148
});
139149

140150
it('returns results as an object', async function () {
141-
expect(results.info).to.haveOwnProperty('test_name', task.taskName);
151+
expect(results.info).to.haveOwnProperty('test_name', task.testName);
142152
expect(results.info).to.haveOwnProperty('args');
143153
});
144154

@@ -240,12 +250,12 @@ describe('Task', function () {
240250
options: { promoteLongs: true }
241251
});
242252

243-
expectedFileName = `${task.taskName}.json`;
253+
expectedFileName = `${task.testName}.json`;
244254
if (await exists(expectedFileName)) await rm(expectedFileName);
245255
});
246256

247257
after(async () => {
248-
expectedFileName = `${task.taskName}.json`;
258+
expectedFileName = `${task.testName}.json`;
249259
if (await exists(expectedFileName)) await rm(expectedFileName);
250260
});
251261

0 commit comments

Comments
 (0)