-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathpythonivoker.ts
29 lines (20 loc) · 956 Bytes
/
pythonivoker.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { spawn } from '../testexecutor'
import tl = require('azure-pipelines-task-lib/task');
import constants = require('../constants');
export async function executepythontests(testsToBeExecuted: string[]) {
//public doc link: https://docs.pytest.org/en/7.1.x/how-to/usage.html#specifying-which-tests-to-run
//pytest command like "pytest -v <package.className.testName1> <package.className.testName2> --junitxml=junit.xml"
const executable = constants.PYTEST_EXECUTABLE;
let args: string[] = [];
for (let testcase of testsToBeExecuted) {
args.push(testcase);
}
args.push('--junitxml=junit.xml')
tl.debug("Executing python tests with executable : " + executable);
tl.debug("Executing python tests with args :" + args);
const { status, error } = await spawn(executable, args)
if (error) {
tl.error("Error executing pytest command, " + error);
}
return { exitCode: status ?? 1 }
}