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

Clean up of tests, address PR feedback from previous PR #7332

Merged
merged 1 commit into from
May 30, 2018
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
33 changes: 16 additions & 17 deletions Tasks/XamariniOSV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('XamariniOS L0 Suite', function () {

});

it('run XamariniOSV2 with all default inputs', (done) => {
it('run XamariniOSV2 with all default inputs', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0DefaultInputs.js');
Expand All @@ -24,12 +24,11 @@ describe('XamariniOS L0 Suite', function () {

assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'it should have run nuget restore');
assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run msbuild');
assert(tr.invokedToolCount == 3, 'should have only run 3 commands');
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount === 3, 'should have only run 3 commands');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();

});

it('XamariniOS signing with identifiers', function (done: MochaDone) {
Expand Down Expand Up @@ -205,7 +204,7 @@ describe('XamariniOS L0 Suite', function () {
done();
})

it('run XamariniOSV2 with buildToolLocation set', (done) => {
it('run XamariniOSV2 with buildToolLocation set', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0BuildToolLocation.js');
Expand All @@ -215,70 +214,70 @@ describe('XamariniOS L0 Suite', function () {

assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'it should have run nuget restore');
assert(tr.ran('/home/bin2/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run msbuild');
assert(tr.invokedToolCount == 2, 'should have only run 2 commands');
assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.invokedToolCount === 2, 'should have only run 2 commands');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
})

it('fails when solution is missing', (done) => {
it('fails when solution is missing', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0MissingSolution.js');
const tr = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.invokedToolCount == 0, 'should not have run XamariniOS');
assert(tr.invokedToolCount === 0, 'should not have run XamariniOS');
assert(tr.errorIssues.length > 0, 'should have written to stderr');
assert(tr.failed, 'task should have failed');
assert(tr.errorIssues[0].indexOf('Input required: solution') >= 0, 'wrong error message');

done();
})

it('fails when configuration is missing', (done) => {
it('fails when configuration is missing', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0MissingConfig.js');
const tr = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.invokedToolCount == 0, 'should not have run XamariniOS');
assert(tr.invokedToolCount === 0, 'should not have run XamariniOS');
assert(tr.errorIssues.length > 0, 'should have written to stderr');
assert(tr.failed, 'task should have failed');
assert(tr.errorIssues[0].indexOf('Input required: configuration') >= 0, 'wrong error message');

done();
})

it('fails when msbuildLocation not provided and msbuild is not found', (done) => {
it('fails when msbuildLocation not provided and msbuild is not found', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0ToolsNotFound.js');
const tr = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.invokedToolCount == 0, 'should not have run XamariniOS');
assert(tr.invokedToolCount === 0, 'should not have run XamariniOS');
assert(tr.errorIssues.length > 0, 'should have written to stderr');
assert(tr.failed, 'task should have failed');
assert(tr.errorIssues[0].indexOf('loc_mock_XamariniOSFailed loc_mock_MSB_BuildToolNotFound') >= 0, 'wrong error message');

done();
});

it('fails when msbuildLocation is provided but is incorrect', (done) => {
it('fails when msbuildLocation is provided but is incorrect', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0MSBuildNotFound.js');
const tr = new ttm.MockTestRunner(tp);

tr.run();

assert(tr.invokedToolCount == 0, 'should not have run XamariniOS');
assert(tr.invokedToolCount === 0, 'should not have run XamariniOS');
assert(tr.errorIssues.length > 0, 'should have written to stderr');
assert(tr.failed, 'task should have failed');
assert(tr.errorIssues[0].indexOf('Error: Not found /user/bin/') >= 0, 'wrong error message');
Expand All @@ -287,15 +286,15 @@ describe('XamariniOS L0 Suite', function () {
});

// fails when nuget not found
it('fails when nuget not found', (done) => {
it('fails when nuget not found', function (done: MochaDone) {
this.timeout(1000);

const tp = path.join(__dirname, 'L0NuGetNotFound.js');
const tr = new ttm.MockTestRunner(tp);

tr.run()

assert(tr.invokedToolCount == 0, 'should not have run XamariniOS');
assert(tr.invokedToolCount === 0, 'should not have run XamariniOS');
assert(tr.errorIssues.length > 0, 'should have written to stderr');
assert(tr.failed, 'task should have failed');
assert(tr.errorIssues[0].indexOf('Not found null') >= 0, 'wrong error message');
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0BuildToolLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0CleanBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MissingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MissingSolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0MultipleWildcardMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0OneWildcardMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'win32';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0SignWithIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0SkipNugetRestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
os.platform = () => {
return 'darwin';
}
tr.registerMock('os', os);
Expand Down
2 changes: 1 addition & 1 deletion Tasks/XamariniOSV2/xamarinios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function run() {
tl.setResourcePath(path.join(__dirname, 'task.json'));

// Check platform is macOS since demands are not evaluated on Hosted pools
if (!/^darwin/.test(os.platform())) {
if (os.platform() !== 'darwin') {
throw new Error(tl.loc('BuildRequiresMac'));
}

Expand Down