Skip to content

Commit 45ffdfa

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/intra-expression-inference-with-resolved-calls
# Conflicts: # src/compiler/checker.ts
2 parents fe969b9 + fbd63e9 commit 45ffdfa

File tree

620 files changed

+17465
-8835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

620 files changed

+17465
-8835
lines changed

.c8rc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"reporter": ["lcovonly", "cobertura"],
3+
"src": "src",
4+
"include": ["src/**", "built/local/**"],
5+
"exclude": ["**/node_modules/**"],
6+
"mergeAsync": true
7+
}

.github/workflows/scorecard.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ on:
1717
# Declare default permissions as read only.
1818
permissions: read-all
1919

20-
# Ensure scripts are run with pipefail. See:
21-
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
22-
defaults:
23-
run:
24-
shell: bash
25-
2620
jobs:
2721
analysis:
2822
name: Scorecard analysis
@@ -40,7 +34,7 @@ jobs:
4034
persist-credentials: false
4135

4236
- name: "Run analysis"
43-
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
37+
uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
4438
with:
4539
results_file: results.sarif
4640
results_format: sarif

Herebyfile.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ export const runTests = task({
577577
// task("runtests").flags = {
578578
// "-t --tests=<regex>": "Pattern for tests to run.",
579579
// " --failed": "Runs tests listed in '.failed-tests'.",
580+
// " --coverage": "Generate test coverage using c8",
580581
// "-r --reporter=<reporter>": "The mocha reporter to use.",
581582
// "-i --break": "Runs tests in inspector mode (NodeJS 8 and later)",
582583
// " --keepFailed": "Keep tests in .failed-tests even if they pass",
@@ -714,6 +715,7 @@ export const runTestsParallel = task({
714715
});
715716

716717
// task("runtests-parallel").flags = {
718+
// " --coverage": "Generate test coverage using c8",
717719
// " --light": "Run tests in light mode (fewer verifications, but tests run faster).",
718720
// " --keepFailed": "Keep tests in .failed-tests even if they pass.",
719721
// " --dirty": "Run tests without first cleaning test output directories.",

package-lock.json

Lines changed: 543 additions & 152 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@typescript-eslint/parser": "^5.33.1",
5656
"@typescript-eslint/utils": "^5.33.1",
5757
"azure-devops-node-api": "^12.0.0",
58+
"c8": "^7.14.0",
5859
"chai": "^4.3.7",
5960
"chalk": "^4.1.2",
6061
"chokidar": "^3.5.3",

scripts/build/options.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os from "os";
44
const ci = ["1", "true"].includes(process.env.CI ?? "");
55

66
const parsed = minimist(process.argv.slice(2), {
7-
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint"],
7+
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage"],
88
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
99
alias: {
1010
/* eslint-disable quote-props */
@@ -42,6 +42,7 @@ const parsed = minimist(process.argv.slice(2), {
4242
bundle: true,
4343
typecheck: true,
4444
lint: true,
45+
coverage: false,
4546
}
4647
});
4748

@@ -88,5 +89,6 @@ export default options;
8889
* @property {boolean} bundle
8990
* @property {boolean} typecheck
9091
* @property {boolean} lint
92+
* @property {boolean} coverage
9193
*/
9294
void 0;

scripts/build/tests.mjs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import path from "path";
77

88
import { findUpFile, findUpRoot } from "./findUpDir.mjs";
99
import cmdLineOptions from "./options.mjs";
10-
import { exec } from "./utils.mjs";
10+
import { exec, ExecError } from "./utils.mjs";
1111

1212
const mochaJs = path.resolve(findUpRoot(), "node_modules", "mocha", "bin", "_mocha");
1313
export const localBaseline = "tests/baselines/local/";
1414
export const refBaseline = "tests/baselines/reference/";
1515
export const localRwcBaseline = "internal/baselines/rwc/local";
1616
export const refRwcBaseline = "internal/baselines/rwc/reference";
17+
export const coverageDir = "coverage";
1718

1819
/**
1920
* @param {string} runJs
@@ -35,11 +36,13 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
3536
const keepFailed = cmdLineOptions.keepFailed;
3637
const shards = +cmdLineOptions.shards || undefined;
3738
const shardId = +cmdLineOptions.shardId || undefined;
39+
const coverage = cmdLineOptions.coverage;
3840
if (!cmdLineOptions.dirty) {
3941
if (options.watching) {
4042
console.log(chalk.yellowBright(`[watch] cleaning test directories...`));
4143
}
4244
await cleanTestDirs();
45+
await cleanCoverageDir();
4346

4447
if (options.token?.signaled) {
4548
return;
@@ -128,21 +131,28 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
128131
/** @type {Error | undefined} */
129132
let error;
130133

134+
const savedNodeEnv = process.env.NODE_ENV;
135+
const savedNodeV8Coverage = process.env.NODE_V8_COVERAGE;
131136
try {
132-
setNodeEnvToDevelopment();
137+
process.env.NODE_ENV = "development";
138+
if (coverage) {
139+
process.env.NODE_V8_COVERAGE = path.resolve(coverageDir, "tmp");
140+
}
133141

134-
const { exitCode } = await exec(process.execPath, args, { token: options.token });
135-
if (exitCode !== 0) {
136-
errorStatus = exitCode;
137-
error = new Error(`Process exited with status code ${errorStatus}.`);
142+
await exec(process.execPath, args, { token: options.token });
143+
if (coverage) {
144+
await exec("npm", ["--prefer-offline", "exec", "--", "c8", "report"], { token: options.token });
138145
}
139146
}
140147
catch (e) {
141-
errorStatus = undefined;
148+
errorStatus = e instanceof ExecError ? e.exitCode ?? undefined : undefined;
142149
error = /** @type {Error} */ (e);
143150
}
144151
finally {
145-
restoreSavedNodeEnv();
152+
if (coverage) {
153+
process.env.NODE_V8_COVERAGE = savedNodeV8Coverage;
154+
}
155+
process.env.NODE_ENV = savedNodeEnv;
146156
}
147157

148158
await del("test.config");
@@ -169,6 +179,10 @@ export async function cleanTestDirs() {
169179
await fs.promises.mkdir(localBaseline, { recursive: true });
170180
}
171181

182+
async function cleanCoverageDir() {
183+
await del([coverageDir]);
184+
}
185+
172186
/**
173187
* used to pass data from command line directly to run.js
174188
* @param {string} tests
@@ -200,17 +214,6 @@ export function writeTestConfigFile(tests, runners, light, taskConfigsFolder, wo
200214
fs.writeFileSync("test.config", testConfigContents);
201215
}
202216

203-
/** @type {string | undefined} */
204-
let savedNodeEnv;
205-
function setNodeEnvToDevelopment() {
206-
savedNodeEnv = process.env.NODE_ENV;
207-
process.env.NODE_ENV = "development";
208-
}
209-
210-
function restoreSavedNodeEnv() {
211-
process.env.NODE_ENV = savedNodeEnv;
212-
}
213-
214217
function deleteTemporaryProjectOutput() {
215218
return del(path.join(localBaseline, "projectOutput/"));
216219
}

scripts/build/utils.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function exec(cmd, args, options = {}) {
3535
}
3636
else {
3737
const reason = options.token?.signaled ? options.token.reason ?? new CancelError() :
38-
new Error(`Process exited with code: ${exitCode}`);
38+
new ExecError(exitCode);
3939
reject(reason);
4040
}
4141
subscription?.unsubscribe();
@@ -53,6 +53,19 @@ export async function exec(cmd, args, options = {}) {
5353
}));
5454
}
5555

56+
export class ExecError extends Error {
57+
exitCode;
58+
59+
/**
60+
* @param {number | null} exitCode
61+
* @param {string} message
62+
*/
63+
constructor(exitCode, message = `Process exited with code: ${exitCode}`) {
64+
super(message);
65+
this.exitCode = exitCode;
66+
}
67+
}
68+
5669
/**
5770
* Reads JSON data with optional comments using the LKG TypeScript compiler
5871
* @param {string} jsonPath

0 commit comments

Comments
 (0)