Skip to content

Commit

Permalink
Users/nigurr/fix adapter pattern (#3677)
Browse files Browse the repository at this point in the history
* Ignore case sensitivity while searching Adapters - xunit as an example

* Bumped up task version
  • Loading branch information
Nitin Gurram authored Feb 23, 2017
1 parent 5e1b047 commit 44843fd
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Tasks/VsTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 15
"Patch": 16
},
"demands": [
"vstest"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VsTest/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 2,
"Minor": 0,
"Patch": 15
"Patch": 16
},
"demands": [
"vstest"
Expand Down
5 changes: 3 additions & 2 deletions Tasks/VsTest/vstest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,15 @@ function cleanUp(temporarySettingsFile: string) {

function isNugetRestoredAdapterPresent(rootDirectory: string): boolean {
var allFiles = tl.find(rootDirectory);
var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true });
var adapterFiles = tl.match(allFiles, "**\\packages\\**\\*TestAdapter.dll", { matchBase: true, nocase: true });

if (adapterFiles && adapterFiles.length != 0) {
for (var i = 0; i < adapterFiles.length; i++) {
var adapterFile = adapterFiles[i];
var packageIndex = adapterFile.indexOf('packages') + 7;
var packageFolder = adapterFile.substr(0, packageIndex);
var parentFolder = path.dirname(packageFolder);
var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true });
var solutionFiles = tl.match(allFiles, path.join(parentFolder, "*.sln"), { matchBase: true, nocase: true });
if (solutionFiles && solutionFiles.length != 0) {
return true;
}
Expand Down
30 changes: 29 additions & 1 deletion Tests-Legacy/L0/VsTest/_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ describe('VsTest Suite', function () {
setResponseFile('vstestGood.json');

let tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0'); // response file sets below update1
Expand Down Expand Up @@ -511,6 +511,33 @@ describe('VsTest Suite', function () {
done();
})
.fail((err) => {
console.log(tr.stdout);
done(err);
});
})

it('Vstest task with Nuget restored adapter path', (done) => {

let vstestCmd = [sysVstestLocation, '/source/dir/someFile1', "/logger:trx", "/TestAdapterPath:/source/dir"].join(" ");
setResponseFile('vstestGoodwithNugetAdapter.json');

let tr = new trm.TaskRunner('VSTest');
tr.setInput('testSelector', 'testAssemblies');
tr.setInput('testAssemblyVer2', '/source/dir/someFile1');
tr.setInput('vstestLocationMethod', 'version');
tr.setInput('vsTestVersion', '14.0');

tr.run()
.then(() => {
assert(tr.resultWasSet, 'task should have set a result');
assert(tr.stderr.length == 0, 'should not have written to stderr. error: ' + tr.stderr);
assert(tr.succeeded, 'task should have succeeded');
assert(tr.ran(vstestCmd), 'should have run vstest');
assert(tr.stdout.search(/##vso\[results.publish type=VSTest;mergeResults=false;resultFiles=a.trx;\]/) >= 0, 'should publish test results.');
done();
})
.fail((err) => {
console.log(tr.stdout);
done(err);
});
})
Expand Down Expand Up @@ -565,6 +592,7 @@ describe('VsTest Suite', function () {
done();
})
.fail((err) => {
console.log(tr.stdout);
done(err);
});
})
Expand Down
122 changes: 122 additions & 0 deletions Tests-Legacy/L0/VsTest/vstestGoodwithNugetAdapter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"getVariable": {
"System.DefaultWorkingDirectory": "/source/dir",
"build.sourcesdirectory": "/source/dir",
"VS150COMNTools": "/vs/path",
"VS140COMNTools": "/vs/path",
"VS120COMNTools": "/vs/path",
"vs15Helper": "/path/to/vs15Helper.ps1"
},
"match": {
"**\\packages\\**\\*TestAdapter.dll": [
"/source/dir/packages/adapter/a.TestAdapter.dll",
"/source/dir/packages/adapter/b.testadapter.dll"
],
"\\source\\dir\\*.sln": [
"/source/dir/a.sln"
]
},
"findMatch": {
"/source/dir/some/*pattern": [
"/source/dir/someFile2",
"/source/dir/someFile1"
],
"/source/dir/some/*pattern,!/source/dir/some/*excludePattern": [
"/source/dir/someFile1"
],
"\\source\\dir\\TestResults\\*.trx": [
"a.trx"
],
"/source/dir/someFile1": [
"/source/dir/someFile1"
],
"/search/dir/someFile1": [
"/search/dir/someFile1"
]
},
"exec": {
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile2 /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /TestCaseFilter:testFilter /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /EnableCodeCoverage /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 consoleOptions /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /Settings:settings.runsettings /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /TestAdapterPath:path/to/customadapters": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx /TestAdapterPath:/source/dir": {
"code": 0,
"stdout": "vstest"
},
"some\\path\\to\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\path\\to\\vstest\\directory\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /search/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"\\vs2017\\installation\\folder\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe /source/dir/someFile1 /logger:trx": {
"code": 0,
"stdout": "vstest"
},
"powershell -NonInteractive -ExecutionPolicy Unrestricted -file /path/to/vs15Helper.ps1": {
"code": 0,
"stdout": "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S>\\vs2017\\installation\\folder</S></Objs>"
}
},
"rmRF": {
"\\source\\dir\\TestResults": {
"success": true,
"message": "success"
}
},
"exist": {
"settings.runsettings": true,
"path/to/customadapters": true,
"\\vs\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\TE.TestModes.dll": false,
"some\\path\\to\\vstest.console.exe": true,
"some\\illegal\\path\\to\\vstest.console.exe": false,
"\\path\\to\\vstest\\directory": true
},
"stats": {
"settings.runsettings": {
"isFile": true
},
"some\\path\\to\\vstest.console.exe": {
"isFile": true
},
"path/to/customadapters": {
"isDirectory": true
},
"/source/dir/packages/adapter": {
"isDirectory": true
},
"\\path\\to\\vstest\\directory": {
"isDirectory": true
}
}
}

0 comments on commit 44843fd

Please sign in to comment.