Skip to content

Commit

Permalink
Clean up of tests, address PR feedback from previous PR (#7332)
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuri Gummalla authored May 30, 2018
1 parent 5e2b0e0 commit eb7aa8f
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 35 deletions.
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

0 comments on commit eb7aa8f

Please sign in to comment.