-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathmaveninvoker.ts
39 lines (30 loc) · 1.26 KB
/
maveninvoker.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
30
31
32
33
34
35
36
37
38
39
import { spawn } from '../testexecutor'
import tl = require('azure-pipelines-task-lib/task');
import utils = require('../utils');
import constants = require('../constants');
export async function executemaventests(testsToBeExecuted: string[]) {
//public doc link: https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
//maven command like "mvn test -Dtest=<package.className#testName>,<package.className#testName1>"
const executable = constants.MVN_EXECUTABLE;
const args = []
const testsToRun =[]
for (let tests of testsToBeExecuted) {
const modifiedTest = utils.replaceLastDotWithHash(tests);
testsToRun.push(modifiedTest);
}
if (testsToRun.length > 0)
{
const testsList = testsToRun.join(',')
const dtest = constants.MAVEN_DTEST;
const combinedTestArgs = dtest + testsList;
args.push('test');
args.push(combinedTestArgs);
}
tl.debug("Executing java maven tests with executable : " + executable);
tl.debug("Executing java maven tests with args :" + args);
const { status, error } = await spawn(executable, args)
if (error) {
tl.error("Error executing mvn command, " + error);
}
return { exitCode: status ?? 1 }
}