From b37e7e2c5d1accb39e8977d6ff3c81eb46b15973 Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Fri, 11 Jul 2025 09:25:54 -0700 Subject: [PATCH] Move initializeFeatures() to testing-utils This change eliminates the need for setup-codeql.test to import from feature-flags.test, which makes the former run all tests defined in the latter. --- src/feature-flags.test.ts | 8 +------- src/setup-codeql.test.ts | 2 +- src/testing-utils.ts | 8 ++++++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/feature-flags.test.ts b/src/feature-flags.test.ts index 474713733..9e316214f 100644 --- a/src/feature-flags.test.ts +++ b/src/feature-flags.test.ts @@ -15,6 +15,7 @@ import { getRunnerLogger } from "./logging"; import { parseRepositoryNwo } from "./repository"; import { getRecordingLogger, + initializeFeatures, LoggedMessage, mockCodeQLVersion, mockFeatureFlagApiEndpoint, @@ -552,13 +553,6 @@ function assertAllFeaturesUndefinedInApi( } } -export function initializeFeatures(initialValue: boolean) { - return Object.keys(featureConfig).reduce((features, key) => { - features[key] = initialValue; - return features; - }, {}); -} - function setUpFeatureFlagTests( tmpDir: string, logger = getRunnerLogger(true), diff --git a/src/setup-codeql.test.ts b/src/setup-codeql.test.ts index 04fb54f7a..ac015953b 100644 --- a/src/setup-codeql.test.ts +++ b/src/setup-codeql.test.ts @@ -5,7 +5,6 @@ import * as sinon from "sinon"; import * as actionsUtil from "./actions-util"; import { Feature, FeatureEnablement } from "./feature-flags"; -import { initializeFeatures } from "./feature-flags.test"; import { getRunnerLogger } from "./logging"; import * as setupCodeql from "./setup-codeql"; import { @@ -14,6 +13,7 @@ import { SAMPLE_DEFAULT_CLI_VERSION, SAMPLE_DOTCOM_API_DETAILS, getRecordingLogger, + initializeFeatures, mockBundleDownloadApi, setupActionsVars, setupTests, diff --git a/src/testing-utils.ts b/src/testing-utils.ts index 11899cf39..81aebde6f 100644 --- a/src/testing-utils.ts +++ b/src/testing-utils.ts @@ -14,6 +14,7 @@ import * as defaults from "./defaults.json"; import { CodeQLDefaultVersionInfo, Feature, + featureConfig, FeatureEnablement, } from "./feature-flags"; import { Logger } from "./logging"; @@ -263,6 +264,13 @@ export function createFeatures(enabledFeatures: Feature[]): FeatureEnablement { }; } +export function initializeFeatures(initialValue: boolean) { + return Object.keys(featureConfig).reduce((features, key) => { + features[key] = initialValue; + return features; + }, {}); +} + /** * Mocks the API for downloading the bundle tagged `tagName`. *