Skip to content

Commit 634e5f2

Browse files
authoredMay 4, 2021
Merge pull request #1855 from snyk/feat/propagate-cli-options
feat(@snyk/fix): propagate cli test options
2 parents 12eadfb + d2e7533 commit 634e5f2

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed
 

‎packages/snyk-fix/src/types.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,16 @@ export interface EntityToFix {
185185
readonly workspace: Workspace;
186186
readonly scanResult: ScanResult;
187187
readonly testResult: TestResult;
188-
// options
188+
readonly options: CliTestOptions;
189189
}
190190

191+
// Partial CLI test options interface
192+
// defining only what is used by @snyk/fix
193+
// add more as needed
194+
export interface PythonTestOptions {
195+
command?: string; // python interpreter to use for python tests
196+
}
197+
export type CliTestOptions = PythonTestOptions;
191198
export interface WithError<Original> {
192199
original: Original;
193200
error: CustomError;

‎packages/snyk-fix/test/acceptance/plugins/python/handlers/pip-requirements/update-dependencies/update-dependencies.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,9 @@ function generateEntityToFix(
12431243
testResult: TestResult,
12441244
): snykFix.EntityToFix {
12451245
const entityToFix = {
1246+
options: {
1247+
command: 'python3',
1248+
},
12461249
workspace: {
12471250
path: workspacesPath,
12481251
readFile: async (path: string) => {

‎packages/snyk-fix/test/helpers/generate-entity-to-fix.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { DepGraphData } from '@snyk/dep-graph';
2-
import { EntityToFix, ScanResult, TestResult, FixInfo, SEVERITY } from '../../src/types';
2+
import {
3+
EntityToFix,
4+
ScanResult,
5+
TestResult,
6+
FixInfo,
7+
SEVERITY,
8+
} from '../../src/types';
39

410
export function generateEntityToFix(
511
type: string,
@@ -10,7 +16,10 @@ export function generateEntityToFix(
1016
const scanResult = generateScanResult(type, targetFile);
1117
const testResult = generateTestResult();
1218
const workspace = generateWorkspace(contents, path);
13-
return { scanResult, testResult, workspace };
19+
const cliTestOptions = {
20+
command: 'python3',
21+
};
22+
return { scanResult, testResult, workspace, options: cliTestOptions };
1423
}
1524

1625
function generateWorkspace(contents: string, path?: string) {

‎packages/snyk-fix/test/unit/__snapshots__/fix.spec.ts.snap

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Object {
66
"npm": Object {
77
"originals": Array [
88
Object {
9+
"options": Object {
10+
"command": "python3",
11+
},
912
"scanResult": Object {
1013
"facts": Array [
1114
Object {
@@ -124,6 +127,9 @@ Summary:
124127
},
125128
],
126129
"original": Object {
130+
"options": Object {
131+
"command": "python3",
132+
},
127133
"scanResult": Object {
128134
"facts": Array [
129135
Object {
@@ -215,6 +221,9 @@ Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>. If the iss
215221
"skipped": Array [
216222
Object {
217223
"original": Object {
224+
"options": Object {
225+
"command": "python3",
226+
},
218227
"scanResult": Object {
219228
"facts": Array [
220229
Object {
@@ -282,6 +291,9 @@ Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>. If the iss
282291
},
283292
],
284293
"original": Object {
294+
"options": Object {
295+
"command": "python3",
296+
},
285297
"scanResult": Object {
286298
"facts": Array [
287299
Object {
@@ -360,6 +372,9 @@ Object {
360372
},
361373
],
362374
"original": Object {
375+
"options": Object {
376+
"command": "python3",
377+
},
363378
"scanResult": Object {
364379
"facts": Array [
365380
Object {

‎src/lib/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface TestOptions {
2121
reachableVulnsTimeout?: number;
2222
initScript?: string;
2323
yarnWorkspaces?: boolean;
24+
command?: string; // python interpreter to use for python tests
2425
testDepGraphDockerEndpoint?: string | null;
2526
isDockerUser?: boolean;
2627
/** @deprecated Only used by the legacy `iac test` flow remove once local exec path is GA */

0 commit comments

Comments
 (0)
Please sign in to comment.