-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpesterv10.ts
More file actions
113 lines (95 loc) · 3.51 KB
/
pesterv10.ts
File metadata and controls
113 lines (95 loc) · 3.51 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import tl = require("azure-pipelines-task-lib/task");
import { basename } from "path";
import {
logInfo,
logError,
getSystemAccessToken
} from "./agentSpecific";
export async function run() {
try {
let TestFolder = tl.getInput("TestFolder");
let resultsFile = tl.getInput("resultsFile");
let run32Bit = tl.getInput("run32Bit");
let additionalModulePath = tl.getInput("additionalModulePath");
let Tag = tl.getInput("Tag");
let ExcludeTag = tl.getInput("ExcludeTag");
let CodeCoverageOutputFile = tl.getInput("CodeCoverageOutputFile");
let CodeCoverageFolder = tl.getInput("CodeCoverageFolder");
let ScriptBlock = tl.getInput("ScriptBlock");
let PesterVersion = tl.getInput("PesterVersion");
let FailOnStdErr = tl.getInput("failOnStdErr");
let TargetPesterVersion = "0.0.0";
if (PesterVersion === "OtherVersion") {
TargetPesterVersion = tl.getInput("TargetPesterVersion");
if (!TargetPesterVersion.match(/\d+\.\d+\.\d+/g)) {
logError(`Invalid version number provided for Pester. Please ensure it is in the format x.y.z`);
}
}
// we need to get the verbose flag passed in as script flag
var verbose = (tl.getVariable("System.Debug") === "true");
// find the executeable
let executable = "pwsh";
if (tl.getVariable("AGENT.OS") === "Windows_NT") {
if (!tl.getBoolInput("usePSCore")) {
executable = "powershell.exe";
}
logInfo(`Using executable '${executable}'`);
} else {
logInfo(`Using executable '${executable}' as only only option on '${tl.getVariable("AGENT.OS")}'`);
}
// we need to not pass the null param
var args = ['"' + __dirname + "/Pester.ps1" + '"',
"-TestFolder", TestFolder,
"-resultsFile", resultsFile,
"-run32Bit", run32Bit,
"-FailOnStdErr", FailOnStdErr,
];
if (additionalModulePath) {
args.push("-additionalModulePath");
args.push(additionalModulePath);
}
if (Tag) {
args.push("-Tag");
args.push(Tag);
}
if (ExcludeTag) {
args.push("-ExcludeTag");
args.push(ExcludeTag);
}
if (CodeCoverageOutputFile) {
args.push("-CodeCoverageOutputFile");
args.push(CodeCoverageOutputFile);
}
if (CodeCoverageFolder) {
args.push("-CodeCoverageFolder");
args.push(CodeCoverageFolder);
}
if (ScriptBlock) {
args.push("-ScriptBlock");
args.push(ScriptBlock);
}
if (verbose) {
args.push("-Verbose");
}
if (TargetPesterVersion !== "0.0.0") {
args.push("-TargetPesterVersion");
args.push(TargetPesterVersion);
}
logInfo(`${executable} ${args.join(" ")}`);
var spawn = require("child_process").spawn, child;
child = spawn(executable, args, {windowsVerbatimArguments: true});
child.stdout.on("data", function (data) {
logInfo(data.toString());
});
child.stderr.on("data", function (data) {
logError(data.toString());
});
child.on("exit", function () {
logInfo("Pester Script finished");
});
}
catch (err) {
logError(err);
}
}
run();