Skip to content

Commit e39a686

Browse files
committed
Rename existing task to v9 to allow side by side versioning
1 parent 31a8cb7 commit e39a686

File tree

103 files changed

+115
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+115
-1
lines changed
File renamed without changes.

Extension/task/HelperModule.psm1 Extension/PesterTask/PesterV9/HelperModule.psm1

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function Import-Pester {
5151
}
5252

5353
if ($Version -eq "latest") {
54-
$NewestPester = Find-Module -Name Pester | Sort-Object Version -Descending | Select-Object -First 1
54+
$NewestPester = Find-Module -Name Pester -MaximumVersion 4.99.99 | Sort-Object Version -Descending | Select-Object -First 1
5555

5656
If ((Get-Module Pester -ListAvailable | Sort-Object Version -Descending| Select-Object -First 1).Version -lt $NewestPester.Version) {
5757
Install-Module -Name Pester -RequiredVersion $NewestPester.Version -Scope CurrentUser -Force -Repository $NewestPester.Repository -SkipPublisherCheck

Extension/task/Pester.ps1 Extension/PesterTask/PesterV9/Pester.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ param
4343
[string]$TargetPesterVersion = "latest"
4444
)
4545

46+
if ($TargetPesterVersion -match '^5') {
47+
Write-Host "##vso[task.logissue type=error]This version of the task does not support Pester V5, please use task version 10 or higher."
48+
}
4649
Write-Host "scriptFolder $scriptFolder"
4750
Write-Host "resultsFile $resultsFile"
4851
Write-Host "run32Bit $run32Bit"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Extension/PesterTask/src/pesterv10.ts

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import tl = require("vsts-task-lib/task");
2+
import { basename } from "path";
3+
4+
import {
5+
logInfo,
6+
logError,
7+
getSystemAccessToken
8+
} from "./agentSpecific";
9+
10+
export async function run() {
11+
try {
12+
13+
let scriptFolder = tl.getInput("scriptFolder");
14+
let resultsFile = tl.getInput("resultsFile");
15+
let run32Bit = tl.getInput("run32Bit");
16+
let additionalModulePath = tl.getInput("additionalModulePath");
17+
let Tag = tl.getInput("Tag");
18+
let ExcludeTag = tl.getInput("ExcludeTag");
19+
let CodeCoverageOutputFile = tl.getInput("CodeCoverageOutputFile");
20+
let CodeCoverageFolder = tl.getInput("CodeCoverageFolder");
21+
let ScriptBlock = tl.getInput("ScriptBlock");
22+
let PesterVersion = tl.getInput("PesterVersion");
23+
24+
let TargetPesterVersion = "0.0.0";
25+
if (PesterVersion === "OtherVersion") {
26+
TargetPesterVersion = tl.getInput("TargetPesterVersion");
27+
if (!TargetPesterVersion.match(/\d+\.\d+\.\d+/g)) {
28+
logError(`Invalid version number provided for Pester. Please ensure it is in the format x.y.z`);
29+
}
30+
}
31+
32+
// we need to get the verbose flag passed in as script flag
33+
var verbose = (tl.getVariable("System.Debug") === "true");
34+
35+
// find the executeable
36+
let executable = "pwsh";
37+
if (tl.getVariable("AGENT.OS") === "Windows_NT") {
38+
if (!tl.getBoolInput("usePSCore")) {
39+
executable = "powershell.exe";
40+
}
41+
logInfo(`Using executable '${executable}'`);
42+
} else {
43+
logInfo(`Using executable '${executable}' as only only option on '${tl.getVariable("AGENT.OS")}'`);
44+
}
45+
46+
// we need to not pass the null param
47+
var args = [__dirname + "\\Pester.ps1",
48+
"-scriptFolder", scriptFolder,
49+
"-resultsFile", resultsFile,
50+
"-run32Bit", run32Bit,
51+
];
52+
53+
if (additionalModulePath) {
54+
args.push("-additionalModulePath");
55+
args.push(additionalModulePath);
56+
}
57+
58+
if (Tag) {
59+
args.push("-Tag");
60+
args.push(Tag);
61+
}
62+
63+
if (ExcludeTag) {
64+
args.push("-ExcludeTag");
65+
args.push(ExcludeTag);
66+
}
67+
68+
if (CodeCoverageOutputFile) {
69+
args.push("-CodeCoverageOutputFile");
70+
args.push(CodeCoverageOutputFile);
71+
}
72+
73+
if (CodeCoverageFolder) {
74+
args.push("-CodeCoverageFolder");
75+
args.push(CodeCoverageFolder);
76+
}
77+
78+
if (ScriptBlock) {
79+
args.push("-ScriptBlock");
80+
args.push(ScriptBlock);
81+
}
82+
83+
if (verbose) {
84+
args.push("-Verbose");
85+
}
86+
87+
if (TargetPesterVersion !== "0.0.0") {
88+
args.push("-TargetPesterVersion");
89+
args.push(TargetPesterVersion);
90+
}
91+
92+
logInfo(`${executable} ${args.join(" ")}`);
93+
94+
var spawn = require("child_process").spawn, child;
95+
child = spawn(executable, args);
96+
child.stdout.on("data", function (data) {
97+
logInfo(data.toString());
98+
});
99+
child.stderr.on("data", function (data) {
100+
logError(data.toString());
101+
});
102+
child.on("exit", function () {
103+
logInfo("Pester Script finished");
104+
});
105+
}
106+
catch (err) {
107+
logError(err);
108+
}
109+
}
110+
111+
run();
File renamed without changes.

0 commit comments

Comments
 (0)