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

[XcodeV5] Fixed issue for post-job when tests results are empty #14527

Merged
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
14 changes: 14 additions & 0 deletions Tasks/XcodeV5/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,20 @@ describe('Xcode L0 Suite', function () {
done();
});

it('Empty test results should not be published in postexecution', function (done: MochaDone) {
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);

let tp = path.join(__dirname, 'L0EmptyTestResultsNotPublishedInPostExecutionJob.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.succeeded, 'post xcode task should have succeeded');
assert(tr.stdout.indexOf('##vso[task.issue type=warning;]loc_mock_NoTestResultsFound /home/build/**/build/reports/junit.xml') > 0,
'test result should not have been published when they are empty');
done();
});

it('Test results publishing should fail if xcpretty is not installed', function (done: MochaDone) {
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import path = require('path');
import os = require('os');

let taskPath = path.join(__dirname, '..', 'postxcode.js');
let tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

process.env['HOME'] = '/users/test'; //replace with mock of setVariable when task-lib has the support

// Xcode task run tests
tr.setInput('actions', 'test');
tr.setInput('xcWorkspacePath', '**/*.xcodeproj/project.xcworkspace');
tr.setInput('scheme', 'testScheme');
tr.setInput('xcodeVersion', 'default');
tr.setInput('xcodeDeveloperDir', '');
tr.setInput('packageApp', 'false');
tr.setInput('signingOption', 'default');
tr.setInput('destinationPlatformOption', 'default');
tr.setInput('destinationPlatform', '');
tr.setInput('destinationTypeOption', 'simulators');
tr.setInput('destinationSimulators', 'iPhone 7');
tr.setInput('destinationDevices', '');
tr.setInput('useXcpretty', 'true');
tr.setInput('publishJUnitResults', 'true');
tr.setInput('cwd', '/home/build');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
"getVariable": {
"HOME": "/users/test"
},
"which": {
"xcpretty": "/users/xcpretty"
},
"findMatch": {
"/home/build/**/build/reports/junit.xml": []
}
};
tr.setAnswers(a);

os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);

tr.run();

2 changes: 1 addition & 1 deletion Tasks/XcodeV5/postxcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function run() {
matchingTestResultsFiles = [testResultsFiles];
}

if (!matchingTestResultsFiles) {
if (!matchingTestResultsFiles || matchingTestResultsFiles.length === 0) {
tl.warning(tl.loc('NoTestResultsFound', testResultsFiles));
} else {
const TESTRUN_SYSTEM = "VSTS - xcode";
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XcodeV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 5,
"Minor": 184,
"Patch": 0
"Patch": 1
},
"releaseNotes": "This version of the task is compatible with Xcode 8 - 11. Features that were solely to maintain compatibility with Xcode 7 have been removed. This task has better options for using Microsoft-hosted macOS agents.",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XcodeV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 5,
"Minor": 184,
"Patch": 0
"Patch": 1
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down