Deprecate isInTestMode in favour of a more clearly named method

This commit is contained in:
Michael B. Gale
2026-10-07 20:11:46 +01:00
parent 75ea4cb2e4
commit ebd711ff66
2 changed files with 26 additions and 2 deletions

11
lib/entry-points.js generated
View File

@@ -166145,6 +166145,15 @@ var ReadOnlyEnv = class {
entries() {
return Object.entries(this.vars);
}
/**
* Gets a value indicating whether we should skip uploads of
* all kinds (SARIF results, status reports, DBs, ...).
*
* This is not guaranteed to be set in all test environments.
*/
isSkippingUploadsInTests() {
return this.getOptional("CODEQL_ACTION_TEST_MODE" /* TEST_MODE */) === "true";
}
/**
* Gets a value indicative of whether we are in a testing environment
* by testing whether the value of the `NODE_ENV` variable is "test".
@@ -166185,7 +166194,7 @@ function getEnv(env = process.env) {
return new Env(env);
}
function isInTestMode() {
return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true";
return getEnv().isSkippingUploadsInTests();
}
function exportVariable2(name, val) {
const env = getEnv();

View File

@@ -304,6 +304,16 @@ export class ReadOnlyEnv<T extends string | undefined = string | undefined> {
return Object.entries(this.vars);
}
/**
* Gets a value indicating whether we should skip uploads of
* all kinds (SARIF results, status reports, DBs, ...).
*
* This is not guaranteed to be set in all test environments.
*/
public isSkippingUploadsInTests(): boolean {
return this.getOptional(EnvVar.TEST_MODE) === "true";
}
/**
* Gets a value indicative of whether we are in a testing environment
* by testing whether the value of the `NODE_ENV` variable is "test".
@@ -366,9 +376,14 @@ export function getEnv(env: NodeJS.ProcessEnv = process.env): Env {
* Returns whether we are in test mode. This is used by CodeQL Action PR checks.
*
* In test mode, we skip several uploads (SARIF results, status reports, DBs, ...).
*
* @deprecated
* The purpose of this function is ambiguous. Use `isSkippingUploadsInTests` on
* a `ReadOnlyEnv` instance instead for equivalent behaviour. Use `isTestingEnv`
* to determine if we are running in a unit test.
*/
export function isInTestMode(): boolean {
return process.env[EnvVar.TEST_MODE] === "true";
return getEnv().isSkippingUploadsInTests();
}
/**