Merge pull request #1128 from github/criemen/lua-tracer-ff-2
Simplify tests for the Lua tracer FF in analyze-action.
This commit is contained in:
commit
e8c48cc8cf
3 changed files with 124 additions and 163 deletions
97
lib/analyze.test.js
generated
97
lib/analyze.test.js
generated
|
|
@ -231,52 +231,53 @@ const stubConfig = {
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
injectedMlQueries: false,
|
injectedMlQueries: false,
|
||||||
};
|
};
|
||||||
(0, ava_1.default)("createdDBForScannedLanguages() Lua feature flag enabled, but old CLI", async (t) => {
|
for (const options of [
|
||||||
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
{
|
||||||
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
name: "Lua feature flag enabled, but old CLI",
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
version: "2.9.0",
|
||||||
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
|
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||||
// call listener on `codeql resolve extractor`
|
yesFlagSet: false,
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
noFlagSet: false,
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
},
|
||||||
await promise;
|
{
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
name: "Lua feature flag disabled, with old CLI",
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
version: "2.9.0",
|
||||||
});
|
featureFlags: [],
|
||||||
(0, ava_1.default)("createdDBForScannedLanguages() Lua feature flag disabled, with old CLI", async (t) => {
|
yesFlagSet: false,
|
||||||
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
noFlagSet: false,
|
||||||
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
},
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
{
|
||||||
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
|
name: "Lua feature flag enabled, with new CLI",
|
||||||
// call listener on `codeql resolve extractor`
|
version: "2.10.0",
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
yesFlagSet: true,
|
||||||
await promise;
|
noFlagSet: false,
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
},
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
{
|
||||||
});
|
name: "Lua feature flag disabled, with new CLI",
|
||||||
(0, ava_1.default)("createdDBForScannedLanguages() Lua feature flag enabled, with new CLI", async (t) => {
|
version: "2.10.0",
|
||||||
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
featureFlags: [],
|
||||||
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
yesFlagSet: false,
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
noFlagSet: true,
|
||||||
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
|
},
|
||||||
// call listener on `codeql resolve extractor`
|
]) {
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
(0, ava_1.default)(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
||||||
await promise;
|
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
||||||
t.true(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but is not");
|
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)(options.featureFlags));
|
||||||
});
|
// call listener on `codeql resolve extractor`
|
||||||
(0, ava_1.default)("createdDBForScannedLanguages() Lua feature flag disabled, with new CLI", async (t) => {
|
const mockToolRunner = runnerConstructorStub.getCall(0);
|
||||||
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
||||||
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
await promise;
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
if (options.yesFlagSet)
|
||||||
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([]));
|
t.true(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
|
||||||
// call listener on `codeql resolve extractor`
|
else
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
if (options.noFlagSet)
|
||||||
await promise;
|
t.true(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
|
||||||
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but is present");
|
else
|
||||||
t.true(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but is absent");
|
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
//# sourceMappingURL=analyze.test.js.map
|
//# sourceMappingURL=analyze.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -272,118 +272,78 @@ const stubConfig: Config = {
|
||||||
injectedMlQueries: false,
|
injectedMlQueries: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
test("createdDBForScannedLanguages() Lua feature flag enabled, but old CLI", async (t) => {
|
for (const options of [
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
{
|
||||||
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
name: "Lua feature flag enabled, but old CLI",
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
version: "2.9.0",
|
||||||
|
featureFlags: [FeatureFlag.LuaTracerConfigEnabled],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag disabled, with old CLI",
|
||||||
|
version: "2.9.0",
|
||||||
|
featureFlags: [],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag enabled, with new CLI",
|
||||||
|
version: "2.10.0",
|
||||||
|
featureFlags: [FeatureFlag.LuaTracerConfigEnabled],
|
||||||
|
yesFlagSet: true,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag disabled, with new CLI",
|
||||||
|
version: "2.10.0",
|
||||||
|
featureFlags: [],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: true,
|
||||||
|
},
|
||||||
|
]) {
|
||||||
|
test(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
|
||||||
|
|
||||||
const promise = createdDBForScannedLanguages(
|
const promise = createdDBForScannedLanguages(
|
||||||
codeqlObject,
|
codeqlObject,
|
||||||
stubConfig,
|
stubConfig,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
createFeatureFlags([FeatureFlag.LuaTracerConfigEnabled])
|
createFeatureFlags(options.featureFlags)
|
||||||
);
|
);
|
||||||
// call listener on `codeql resolve extractor`
|
// call listener on `codeql resolve extractor`
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
const mockToolRunner = runnerConstructorStub.getCall(0);
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
||||||
await promise;
|
await promise;
|
||||||
t.false(
|
if (options.yesFlagSet)
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
t.true(
|
||||||
"--internal-use-lua-tracing"
|
runnerConstructorStub.secondCall.args[1].includes(
|
||||||
),
|
"--internal-use-lua-tracing"
|
||||||
"--internal-use-lua-tracing should be absent, but it is present"
|
),
|
||||||
);
|
"--internal-use-lua-tracing should be present, but it is absent"
|
||||||
t.false(
|
);
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
else
|
||||||
"--no-internal-use-lua-tracing"
|
t.false(
|
||||||
),
|
runnerConstructorStub.secondCall.args[1].includes(
|
||||||
"--no-internal-use-lua-tracing should be absent, but it is present"
|
"--internal-use-lua-tracing"
|
||||||
);
|
),
|
||||||
});
|
"--internal-use-lua-tracing should be absent, but it is present"
|
||||||
|
);
|
||||||
test("createdDBForScannedLanguages() Lua feature flag disabled, with old CLI", async (t) => {
|
if (options.noFlagSet)
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
t.true(
|
||||||
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
runnerConstructorStub.secondCall.args[1].includes(
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
"--no-internal-use-lua-tracing"
|
||||||
|
),
|
||||||
const promise = createdDBForScannedLanguages(
|
"--no-internal-use-lua-tracing should be present, but it is absent"
|
||||||
codeqlObject,
|
);
|
||||||
stubConfig,
|
else
|
||||||
getRunnerLogger(true),
|
t.false(
|
||||||
createFeatureFlags([FeatureFlag.LuaTracerConfigEnabled])
|
runnerConstructorStub.secondCall.args[1].includes(
|
||||||
);
|
"--no-internal-use-lua-tracing"
|
||||||
// call listener on `codeql resolve extractor`
|
),
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
"--no-internal-use-lua-tracing should be absent, but it is present"
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
);
|
||||||
await promise;
|
});
|
||||||
t.false(
|
}
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--internal-use-lua-tracing should be absent, but it is present"
|
|
||||||
);
|
|
||||||
t.false(
|
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--no-internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--no-internal-use-lua-tracing should be absent, but it is present"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("createdDBForScannedLanguages() Lua feature flag enabled, with new CLI", async (t) => {
|
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
|
||||||
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
|
||||||
|
|
||||||
const promise = createdDBForScannedLanguages(
|
|
||||||
codeqlObject,
|
|
||||||
stubConfig,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
createFeatureFlags([FeatureFlag.LuaTracerConfigEnabled])
|
|
||||||
);
|
|
||||||
// call listener on `codeql resolve extractor`
|
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
|
||||||
await promise;
|
|
||||||
t.true(
|
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--internal-use-lua-tracing should be present, but is not"
|
|
||||||
);
|
|
||||||
t.false(
|
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--no-internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--no-internal-use-lua-tracing should be absent, but it is present"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("createdDBForScannedLanguages() Lua feature flag disabled, with new CLI", async (t) => {
|
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
|
||||||
const codeqlObject = await getCodeQLForTesting("codeql/for-testing");
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
|
||||||
|
|
||||||
const promise = createdDBForScannedLanguages(
|
|
||||||
codeqlObject,
|
|
||||||
stubConfig,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
createFeatureFlags([])
|
|
||||||
);
|
|
||||||
// call listener on `codeql resolve extractor`
|
|
||||||
const mockToolRunner = runnerConstructorStub.getCall(0);
|
|
||||||
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
|
||||||
await promise;
|
|
||||||
t.false(
|
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--internal-use-lua-tracing should be absent, but is present"
|
|
||||||
);
|
|
||||||
t.true(
|
|
||||||
runnerConstructorStub.secondCall.args[1].includes(
|
|
||||||
"--no-internal-use-lua-tracing"
|
|
||||||
),
|
|
||||||
"--no-internal-use-lua-tracing should be present, but is absent"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue