Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L0 tests for Xamarin tasks #1732

Merged
merged 7 commits into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Tasks/XamarinAndroid/xamarinandroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ else {
//find xbuild location to use
var xbuildToolPath = tl.which('xbuild');
if(xbuildLocation) {
xbuildToolPath = xbuildLocation + '/xbuild';
xbuildToolPath = path.join(xbuildLocation, 'xbuild');
if (!tl.exist(xbuildToolPath)) {
xbuildToolPath = path.join(xbuildLocation, 'xbuild.exe');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing the explicit check for xbuild.exe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to handle running it on Windows or *nix. On Windows it has the extension .exe, but not on other OSes. Is there a better way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a way to check for os version like we do in Xamarin Licensing task.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there isn't a way to mock that OS check. That's why I tried to avoid that here. The TaskLib really needs a method that allows the task to check the OS (tl.isWin). That way it could be mocked and all paths can be fully tested.

}
tl.checkPath(xbuildToolPath, 'xbuild');
}
if(!xbuildToolPath) {
tl.error('xbuild was not found in the path.');
Expand Down
12 changes: 9 additions & 3 deletions Tasks/XamarinComponentRestore/xamarincomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ xamarinComponentTool.arg(tl.getInput('email', true));
xamarinComponentTool.arg('-p');
xamarinComponentTool.arg(tl.getInput('password', true));

var solutionPath = tl.getPathInput('solution', true, false);
var solutionInput = tl.getPathInput('solution', true, false);
var solutionPath = solutionInput;
if(tl.filePathSupplied('solution'))
{
var solutionMatches = tl.glob(solutionPath);
Expand All @@ -41,9 +42,14 @@ if(tl.filePathSupplied('solution'))
}

solutionPath = solutionMatches[0];
} else {
solutionPath = undefined;
}
} else {
tl.debug('No solutions found');
}

if (!solutionPath) {
tl.error(tl.loc('XamarinComponentRestoreFailed', 'No solutions found matching the input: ' + solutionInput));
tl.exit(1);
}

tl.debug("Restoring components for " + solutionPath);
Expand Down
3 changes: 3 additions & 0 deletions Tasks/XamarinLicense/xamarinlicense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,7 @@ if (action == 'Activate') {
}
tl.exit(0);
});
} else {
tl.error('Unknown action: ' + action);
tl.exit(1);
}
20 changes: 9 additions & 11 deletions Tasks/XamarinTestCloud/xamarintestcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import fs = require('fs');
import path = require('path');
import shell = require('shelljs');
import tl = require('vsts-task-lib/task');

// Get inputs
Expand Down Expand Up @@ -41,10 +40,14 @@ var onError = function (errorMsg) {
tl.exit(1);
}

// Find location of mono
var monoPath = tl.which('mono', true);
tl.debug("monoPath: " + monoPath);

// Resolve apps for the specified value or pattern
if (app.indexOf('*') == -1 && app.indexOf('?') == -1) {
// Check literal path to a single app file
if (!fs.existsSync(app)) {
if (!tl.exist(app)) {
onError('The specified app file does not exist: ' + app);
}

Expand All @@ -65,19 +68,20 @@ else {
}

// Check and add parameter for test assembly directory
if (!shell.test('-d', testDir)) {
if (!tl.exist(testDir)) {
onError('The test assembly directory does not exist: ' + testDir);
}

// Ensure that $testCloudLocation specifies test-cloud.exe (case-sensitive)
if (path.basename(testCloudLocation) != 'test-cloud.exe') {
throw "test-cloud.exe location must end with '\\test-cloud.exe'."
tl.debug("testCloudLocation = " + testCloudLocation);
onError("test-cloud.exe location must end with '\\test-cloud.exe'.");
}

// Locate test-cloud.exe (part of the Xamarin.UITest NuGet package)
if (testCloudLocation.indexOf('*') == -1 && testCloudLocation.indexOf('?') == -1) {
// Check literal path to test-cloud.exe
if (!fs.existsSync(testCloudLocation)) {
if (!tl.exist(testCloudLocation)) {
onError('test-cloud.exe does not exist at the specified location: ' + testCloudLocation);
}

Expand All @@ -100,12 +104,6 @@ else {
var testCloud = testCloudExecutables[0];
}

// Find location of mono
var monoPath = tl.which('mono');
if (!monoPath) {
onError('mono was not found in the path.');
}

// Invoke test-cloud.exe for each app file
var buildId = tl.getVariable('build.buildId');
var appFileIndex = 0;
Expand Down
29 changes: 14 additions & 15 deletions Tasks/XamariniOS/xamarinios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,24 @@ var args = tl.getInput('args');
var packageApp = tl.getBoolInput('packageApp');
var buildForSimulator = tl.getBoolInput('forSimulator');
var device = (buildForSimulator) ? 'iPhoneSimulator' : 'iPhone';
tl.debug('Device: ' + device);
tl.debug('device: ' + device);
var xbuildLocation = tl.getInput('mdtoolLocation', false);
var cwd = tl.getInput('cwd');

// Get path to xbuild
var xbuildToolPath = tl.which('xbuild');
var xbuildLocation = tl.getInput('mdtoolLocation', false);
var xbuildToolPath = undefined;
if (xbuildLocation) {
xbuildToolPath = xbuildLocation + '/xbuild';
xbuildToolPath = path.join(xbuildLocation, 'xbuild');
tl.checkPath(xbuildToolPath, 'xbuild');
}
if (!xbuildToolPath) {
tl.error('xbuild was not found in the path.');
tl.exit(1);
} else {
xbuildToolPath = tl.which('xbuild', true);
}

// Find location of nuget
var nugetPath = tl.which('nuget');
if (!nugetPath) {
tl.error('nuget was not found in the path.');
tl.exit(1);
}
var nugetPath = tl.which('nuget', true);

//Process working directory
var buildSourceDirectory = tl.getVariable('build.sourceDirectory') || tl.getVariable('build.sourcesDirectory');
var cwd = tl.getInput('cwd') || buildSourceDirectory;
var cwd = cwd || tl.getVariable('build.sourceDirectory') || tl.getVariable('build.sourcesDirectory');
tl.cd(cwd);

// Prepare function for tool execution failure
Expand Down Expand Up @@ -147,9 +141,14 @@ nugetRunner.exec()
.then(function (code) {
tl.exit(code);
})
} else {
tl.setResult(tl.TaskResult.Succeeded, '');
}
})
} else {
tl.setResult(tl.TaskResult.Succeeded, '');
}

})
.fail(onFailedExecution) //xbuild
})
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/ANT/antFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"checkPath" : {
"/usr/local/bin/ANT": true,
"/build/build.xml": true
},
"getVariable" : {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/ANT/antGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"checkPath" : {
"/usr/local/bin/ANT": true,
"/build/build.xml": true,
"/usr/local/bin/ANT2": true
},
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/ANT/antVersionFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"checkPath" : {
"/usr/local/bin/ANT": true,
"/build/build.xml": true
}
}
4 changes: 4 additions & 0 deletions Tests/L0/CMake/cmakeFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"cmake": "/usr/local/bin/cmake",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/cmake": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/cmake ..": {
"code": 1,
Expand Down
4 changes: 4 additions & 0 deletions Tests/L0/CMake/cmakeGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"cmake": "/usr/local/bin/cmake",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/cmake": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/cmake ..": {
"code": 0,
Expand Down
3 changes: 3 additions & 0 deletions Tests/L0/CMake/cmakeNoCwd.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"which": {
"cmake": "/usr/local/bin/cmake"
},
"checkPath": {
"/usr/local/bin/cmake": true
}
}
4 changes: 4 additions & 0 deletions Tests/L0/CmdLine/cmdlineFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"cmd": "/usr/local/bin/cmd",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/cmd": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/cmd /c cmd": {
"code": 1,
Expand Down
4 changes: 4 additions & 0 deletions Tests/L0/CmdLine/cmdlineGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"cmd": "/usr/local/bin/cmd",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/cmd": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/cmd /c cmd": {
"code": 0,
Expand Down
3 changes: 3 additions & 0 deletions Tests/L0/CmdLine/cmdlineNoCwd.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"which": {
"cmd": "/usr/local/bin/cmd"
},
"checkPath": {
"/usr/local/bin/cmd": true
}
}
4 changes: 4 additions & 0 deletions Tests/L0/CmdLine/cmdlineStderrFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"cmd": "/usr/local/bin/cmd",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/cmd": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/cmd /c cmd": {
"code": 0,
Expand Down
2 changes: 2 additions & 0 deletions Tests/L0/Grunt/gruntFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
}
},
"checkPath": {
"/usr/local/bin/grunt": true,
"/usr/local/bin/node": true,
"gruntfile.js": true
},
"exist": {
Expand Down
2 changes: 2 additions & 0 deletions Tests/L0/Grunt/gruntGlobalGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
}
},
"checkPath": {
"/usr/local/bin/grunt": true,
"/usr/local/bin/node": true,
"gruntfile.js": true
},
"exist": {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/Grunt/gruntLocalGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
},
"checkPath": {
"/usr/local/bin/node": true,
"gruntfile.js": true
},
"exist": {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/Grunt/gruntNoGruntCli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/node": true,
"gruntfile.js": true
}
}
1 change: 1 addition & 0 deletions Tests/L0/Grunt/gruntNoGruntFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/node": true,
"gruntfile.js": false
}
}
1 change: 1 addition & 0 deletions Tests/L0/Gulp/gulpFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
},
"checkPath": {
"/usr/local/bin/gulp": true,
"gulpfile.js": true
},
"exist": {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/Gulp/gulpGlobalGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}
},
"checkPath": {
"/usr/local/bin/gulp": true,
"gulpfile.js": true
},
"exist": {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/Gulp/gulpLocalGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
},
"checkPath": {
"/usr/local/bin/node": true,
"gulpfile.js": true
},
"exist": {
Expand Down
1 change: 1 addition & 0 deletions Tests/L0/Gulp/gulpNoGulp.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/node": true,
"gulpfile.js": true
}
}
4 changes: 4 additions & 0 deletions Tests/L0/Npm/npmFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"npm": "/usr/local/bin/npm",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/npm": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/npm install npm -g": {
"code": 1,
Expand Down
4 changes: 4 additions & 0 deletions Tests/L0/Npm/npmGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"npm": "/usr/local/bin/npm",
"node": "/usr/local/bin/node"
},
"checkPath": {
"/usr/local/bin/npm": true,
"/usr/local/bin/node": true
},
"exec": {
"/usr/local/bin/npm install npm": {
"code": 0,
Expand Down
2 changes: 2 additions & 0 deletions Tests/L0/ShellScript/shellscriptFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
}
},
"checkPath" : {
"/usr/local/bin/bash": true,
"/usr/local/bin/node": true,
"/script.sh" : true
}
}
2 changes: 2 additions & 0 deletions Tests/L0/ShellScript/shellscriptGood.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
}
},
"checkPath" : {
"/usr/local/bin/bash": true,
"/usr/local/bin/node": true,
"/script.sh" : true
}
}
2 changes: 2 additions & 0 deletions Tests/L0/ShellScript/shellscriptStderrFails.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
}
},
"checkPath" : {
"/usr/local/bin/bash": true,
"/usr/local/bin/node": true,
"/script.sh" : true
}
}
Loading