Skip to content

Commit 90aff0e

Browse files
authored
Produce JSON report for archiving by build jobs (#1132)
* Produce JSON report for archiving by build jobs * Want to be able to archive some results as part of build jobs * Fix formatting
1 parent 178695d commit 90aff0e

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
out
22
dist
33
coverage
4+
test-results
45
node_modules
56
default.profraw
67
*.vsix

.mocha-reporter.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the VS Code Swift open source project
4+
//
5+
// Copyright (c) 2024 the VS Code Swift project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
const BaseReporter = require("mocha/lib/reporters/base");
16+
const SpecReporter = require("mocha/lib/reporters/spec");
17+
const JsonReporter = require("mocha/lib/reporters/json");
18+
19+
// Taking inspiration from https://github.com/stanleyhlng/mocha-multi-reporters/issues/108#issuecomment-2028773686
20+
// since mocha-multi-reporters seems to have bugs with newer mocha versions
21+
module.exports = class MultiReporter extends BaseReporter {
22+
constructor(runner, options) {
23+
super(runner, options);
24+
this.reporters = [
25+
new SpecReporter(runner, {
26+
reporterOption: options.reporterOption.specReporterOptions,
27+
}),
28+
new JsonReporter(runner, {
29+
reporterOption: options.reporterOption.jsonReporterOptions,
30+
}),
31+
];
32+
}
33+
};

.vscode-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
const { defineConfig } = require("@vscode/test-cli");
16+
const path = require("path");
1617

1718
const isCIBuild = process.env["CI"] === "1";
1819
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
@@ -44,6 +45,12 @@ module.exports = defineConfig({
4445
grep: isFastTestRun ? "@slow" : undefined,
4546
invert: isFastTestRun,
4647
slow: 10000,
48+
reporter: path.join(__dirname, ".mocha-reporter.js"),
49+
reporterOptions: {
50+
jsonReporterOptions: {
51+
output: path.join(__dirname, "test-results", "integration-tests.json"),
52+
},
53+
},
4754
},
4855
reuseMachineInstall: !isCIBuild,
4956
},
@@ -64,6 +71,12 @@ module.exports = defineConfig({
6471
timeout,
6572
forbidOnly: isCIBuild,
6673
slow: 100,
74+
reporter: path.join(__dirname, ".mocha-reporter.js"),
75+
reporterOptions: {
76+
jsonReporterOptions: {
77+
output: path.join(__dirname, "test-results", "unit-tests.json"),
78+
},
79+
},
6780
},
6881
reuseMachineInstall: !isCIBuild,
6982
},

0 commit comments

Comments
 (0)