Skip to content

Commit 44843fd

Browse files
author
Nitin Gurram
authored
Users/nigurr/fix adapter pattern (#3677)
* Ignore case sensitivity while searching Adapters - xunit as an example * Bumped up task version
1 parent 5e1b047 commit 44843fd

File tree

5 files changed

+156
-5
lines changed

5 files changed

+156
-5
lines changed

Tasks/VsTest/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"version": {
1818
"Major": 2,
1919
"Minor": 0,
20-
"Patch": 15
20+
"Patch": 16
2121
},
2222
"demands": [
2323
"vstest"

Tasks/VsTest/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"version": {
1818
"Major": 2,
1919
"Minor": 0,
20-
"Patch": 15
20+
"Patch": 16
2121
},
2222
"demands": [
2323
"vstest"

Tasks/VsTest/vstest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,15 @@ function cleanUp(temporarySettingsFile: string) {
823823

824824
function isNugetRestoredAdapterPresent(rootDirectory: string): boolean {
825825
var allFiles = tl.find(rootDirectory);
826-
var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true });
826+
var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true, nocase: true });
827+
827828
if (adapterFiles && adapterFiles.length != 0) {
828829
for (var i = 0; i < adapterFiles.length; i++) {
829830
var adapterFile = adapterFiles[i];
830831
var packageIndex = adapterFile.indexOf('packages') + 7;
831832
var packageFolder = adapterFile.substr(0, packageIndex);
832833
var parentFolder = path.dirname(packageFolder);
833-
var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true });
834+
var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true, nocase: true });
834835
if (solutionFiles && solutionFiles.length != 0) {
835836
return true;
836837
}

Tests-Legacy/L0/VsTest/_suite.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ describe('VsTest Suite', function () {
414414
setResponseFile('vstestGood.json');
415415

416416
let tr = new trm.TaskRunner('VSTest');
417-
tr.setInput('testSelector', 'testAssemblies');
417+
tr.setInput('testSelector', 'testAssemblies');
418418
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
419419
tr.setInput('vstestLocationMethod', 'version');
420420
tr.setInput('vsTestVersion', '14.0'); // response file sets below update1
@@ -511,6 +511,33 @@ describe('VsTest Suite', function () {
511511
done();
512512
})
513513
.fail((err) => {
514+
console.log(tr.stdout);
515+
done(err);
516+
});
517+
})
518+
519+
it('Vstest task with Nuget restored adapter path', (done) => {
520+
521+
let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx", "/TestAdapterPath:/source/dir"].join(" ");
522+
setResponseFile('vstestGoodwithNugetAdapter.json');
523+
524+
let tr = new trm.TaskRunner('VSTest');
525+
tr.setInput('testSelector', 'testAssemblies');
526+
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
527+
tr.setInput('vstestLocationMethod', 'version');
528+
tr.setInput('vsTestVersion', '14.0');
529+
530+
tr.run()
531+
.then(() => {
532+
assert(tr.resultWasSet, 'task should have set a result');
533+
assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
534+
assert(tr.succeeded, 'task should have succeeded');
535+
assert(tr.ran(vstestCmd), 'should have run vstest');
536+
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
537+
done();
538+
})
539+
.fail((err) => {
540+
console.log(tr.stdout);
514541
done(err);
515542
});
516543
})
@@ -565,6 +592,7 @@ describe('VsTest Suite', function () {
565592
done();
566593
})
567594
.fail((err) => {
595+
console.log(tr.stdout);
568596
done(err);
569597
});
570598
})
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"getVariable": {
3+
"System.DefaultWorkingDirectory": "/source/dir",
4+
"build.sourcesdirectory": "/source/dir",
5+
"VS150COMNTools": "/vs/path",
6+
"VS140COMNTools": "/vs/path",
7+
"VS120COMNTools": "/vs/path",
8+
"vs15Helper": "/path/to/vs15Helper.ps1"
9+
},
10+
"match": {
11+
"**\\packages\\**\\*TestAdapter.dll": [
12+
"/source/dir/packages/adapter/a.TestAdapter.dll",
13+
"/source/dir/packages/adapter/b.testadapter.dll"
14+
],
15+
"\\source\\dir\\*.sln": [
16+
"/source/dir/a.sln"
17+
]
18+
},
19+
"findMatch": {
20+
"/source/dir/some/*pattern": [
21+
"/source/dir/someFile2",
22+
"/source/dir/someFile1"
23+
],
24+
"/source/dir/some/*pattern,!/source/dir/some/*excludePattern": [
25+
"/source/dir/someFile1"
26+
],
27+
"\\source\\dir\\TestResults\\*.trx": [
28+
"a.trx"
29+
],
30+
"/source/dir/someFile1": [
31+
"/source/dir/someFile1"
32+
],
33+
"/search/dir/someFile1": [
34+
"/search/dir/someFile1"
35+
]
36+
},
37+
"exec": {
38+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile2 /source/dir/someFile1 /logger:trx": {
39+
"code": 0,
40+
"stdout": "vstest"
41+
},
42+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
43+
"code": 0,
44+
"stdout": "vstest"
45+
},
46+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /TestCaseFilter:testFilter /logger:trx": {
47+
"code": 0,
48+
"stdout": "vstest"
49+
},
50+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /EnableCodeCoverage /logger:trx": {
51+
"code": 0,
52+
"stdout": "vstest"
53+
},
54+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 consoleOptions /logger:trx": {
55+
"code": 0,
56+
"stdout": "vstest"
57+
},
58+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /Settings:settings.runsettings /logger:trx": {
59+
"code": 0,
60+
"stdout": "vstest"
61+
},
62+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /TestAdapterPath:path/to/customadapters": {
63+
"code": 0,
64+
"stdout": "vstest"
65+
},
66+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /TestAdapterPath:/source/dir": {
67+
"code": 0,
68+
"stdout": "vstest"
69+
},
70+
"some\\path\\to\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
71+
"code": 0,
72+
"stdout": "vstest"
73+
},
74+
"\\path\\to\\vstest\\directory\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
75+
"code": 0,
76+
"stdout": "vstest"
77+
},
78+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /search/dir/someFile1 /logger:trx": {
79+
"code": 0,
80+
"stdout": "vstest"
81+
},
82+
"\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
83+
"code": 0,
84+
"stdout": "vstest"
85+
},
86+
"powershell -NonInteractive -ExecutionPolicy Unrestricted -file /path/to/vs15Helper.ps1": {
87+
"code": 0,
88+
"stdout": "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S>\\vs2017\\installation\\folder</S></Objs>"
89+
}
90+
},
91+
"rmRF": {
92+
"\\source\\dir\\TestResults": {
93+
"success": true,
94+
"message": "success"
95+
}
96+
},
97+
"exist": {
98+
"settings.runsettings": true,
99+
"path/to/customadapters": true,
100+
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\TE.TestModes.dll": false,
101+
"some\\path\\to\\vstest.console.exe": true,
102+
"some\\illegal\\path\\to\\vstest.console.exe": false,
103+
"\\path\\to\\vstest\\directory": true
104+
},
105+
"stats": {
106+
"settings.runsettings": {
107+
"isFile": true
108+
},
109+
"some\\path\\to\\vstest.console.exe": {
110+
"isFile": true
111+
},
112+
"path/to/customadapters": {
113+
"isDirectory": true
114+
},
115+
"/source/dir/packages/adapter": {
116+
"isDirectory": true
117+
},
118+
"\\path\\to\\vstest\\directory": {
119+
"isDirectory": true
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)