From f92cfee7950d55cbf878df12c1ab81a2eab59513 Mon Sep 17 00:00:00 2001 From: madhurig Date: Wed, 30 May 2018 15:37:31 -0400 Subject: [PATCH] Clean up of tests, address PR feedback from previous PR --- Tasks/XamariniOSV2/Tests/L0.ts | 33 +++++++++---------- .../XamariniOSV2/Tests/L0BuildToolLocation.ts | 2 +- Tasks/XamariniOSV2/Tests/L0CleanBuild.ts | 2 +- Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts | 2 +- Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts | 2 +- Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts | 2 +- Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts | 2 +- Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts | 2 +- Tasks/XamariniOSV2/Tests/L0MissingConfig.ts | 2 +- Tasks/XamariniOSV2/Tests/L0MissingSolution.ts | 2 +- .../Tests/L0MultipleWildcardMatch.ts | 2 +- Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts | 2 +- Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts | 2 +- .../XamariniOSV2/Tests/L0OneWildcardMatch.ts | 2 +- Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts | 2 +- Tasks/XamariniOSV2/Tests/L0SignWithIds.ts | 2 +- .../XamariniOSV2/Tests/L0SkipNugetRestore.ts | 2 +- Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts | 2 +- Tasks/XamariniOSV2/xamarinios.ts | 2 +- 19 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Tasks/XamariniOSV2/Tests/L0.ts b/Tasks/XamariniOSV2/Tests/L0.ts index 8bf708404c79..b096a9695e22 100644 --- a/Tasks/XamariniOSV2/Tests/L0.ts +++ b/Tasks/XamariniOSV2/Tests/L0.ts @@ -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'); @@ -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) { @@ -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'); @@ -215,14 +214,14 @@ 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'); @@ -230,7 +229,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -238,7 +237,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -246,7 +245,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -254,7 +253,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -262,7 +261,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -270,7 +269,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -278,7 +277,7 @@ describe('XamariniOS L0 Suite', function () { 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'); @@ -287,7 +286,7 @@ 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'); @@ -295,7 +294,7 @@ describe('XamariniOS L0 Suite', function () { 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'); diff --git a/Tasks/XamariniOSV2/Tests/L0BuildToolLocation.ts b/Tasks/XamariniOSV2/Tests/L0BuildToolLocation.ts index 463a25e5d366..9ced66645adc 100644 --- a/Tasks/XamariniOSV2/Tests/L0BuildToolLocation.ts +++ b/Tasks/XamariniOSV2/Tests/L0BuildToolLocation.ts @@ -59,7 +59,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0CleanBuild.ts b/Tasks/XamariniOSV2/Tests/L0CleanBuild.ts index 3a2c98063ccd..25a177a95dd8 100644 --- a/Tasks/XamariniOSV2/Tests/L0CleanBuild.ts +++ b/Tasks/XamariniOSV2/Tests/L0CleanBuild.ts @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts b/Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts index f85959939176..cf1802be9b92 100644 --- a/Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts +++ b/Tasks/XamariniOSV2/Tests/L0DefaultInputs.ts @@ -59,7 +59,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts b/Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts index 1452a2e5e5f8..4adbd73513be 100644 --- a/Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts +++ b/Tasks/XamariniOSV2/Tests/L0FallbackXbuild.ts @@ -47,7 +47,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts b/Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts index 4983b8bf2586..5e0a3993083e 100644 --- a/Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts +++ b/Tasks/XamariniOSV2/Tests/L0MSBuildDefault.ts @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts b/Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts index 5f5ff1508c1b..3ef895aab347 100644 --- a/Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts +++ b/Tasks/XamariniOSV2/Tests/L0MSBuildLocation.ts @@ -54,7 +54,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts b/Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts index 6d2c3e19dbb7..8dad45ded8d8 100644 --- a/Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts +++ b/Tasks/XamariniOSV2/Tests/L0MSBuildNotFound.ts @@ -35,7 +35,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MissingConfig.ts b/Tasks/XamariniOSV2/Tests/L0MissingConfig.ts index e779139cb511..f52a4b2e4622 100644 --- a/Tasks/XamariniOSV2/Tests/L0MissingConfig.ts +++ b/Tasks/XamariniOSV2/Tests/L0MissingConfig.ts @@ -47,7 +47,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MissingSolution.ts b/Tasks/XamariniOSV2/Tests/L0MissingSolution.ts index 59aad9e62623..33c499ebd464 100644 --- a/Tasks/XamariniOSV2/Tests/L0MissingSolution.ts +++ b/Tasks/XamariniOSV2/Tests/L0MissingSolution.ts @@ -46,7 +46,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0MultipleWildcardMatch.ts b/Tasks/XamariniOSV2/Tests/L0MultipleWildcardMatch.ts index 942da42b1ff5..7777feb02cb8 100644 --- a/Tasks/XamariniOSV2/Tests/L0MultipleWildcardMatch.ts +++ b/Tasks/XamariniOSV2/Tests/L0MultipleWildcardMatch.ts @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts b/Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts index 0b140d7b7625..936474ddde1c 100644 --- a/Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts +++ b/Tasks/XamariniOSV2/Tests/L0NoWildcardMatch.ts @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts b/Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts index 5e3cb88d494e..88f85a744346 100644 --- a/Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts +++ b/Tasks/XamariniOSV2/Tests/L0NuGetNotFound.ts @@ -35,7 +35,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0OneWildcardMatch.ts b/Tasks/XamariniOSV2/Tests/L0OneWildcardMatch.ts index 6780dce775a7..4e4cad3c2255 100644 --- a/Tasks/XamariniOSV2/Tests/L0OneWildcardMatch.ts +++ b/Tasks/XamariniOSV2/Tests/L0OneWildcardMatch.ts @@ -58,7 +58,7 @@ const a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts b/Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts index 01ae4838adf4..02d8b0481e28 100644 --- a/Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts +++ b/Tasks/XamariniOSV2/Tests/L0RunOnWindows.ts @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'win32'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0SignWithIds.ts b/Tasks/XamariniOSV2/Tests/L0SignWithIds.ts index d8e43f5b3ac6..90b6d4d492bf 100644 --- a/Tasks/XamariniOSV2/Tests/L0SignWithIds.ts +++ b/Tasks/XamariniOSV2/Tests/L0SignWithIds.ts @@ -58,7 +58,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0SkipNugetRestore.ts b/Tasks/XamariniOSV2/Tests/L0SkipNugetRestore.ts index 44bd2f9b8ea5..3ff55016826c 100644 --- a/Tasks/XamariniOSV2/Tests/L0SkipNugetRestore.ts +++ b/Tasks/XamariniOSV2/Tests/L0SkipNugetRestore.ts @@ -48,7 +48,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts b/Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts index 56c53ea4d614..157a4df0e39c 100644 --- a/Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts +++ b/Tasks/XamariniOSV2/Tests/L0ToolsNotFound.ts @@ -34,7 +34,7 @@ let a: ma.TaskLibAnswers = { }; tr.setAnswers(a); -os.platform = () => { +os.platform = () => { return 'darwin'; } tr.registerMock('os', os); diff --git a/Tasks/XamariniOSV2/xamarinios.ts b/Tasks/XamariniOSV2/xamarinios.ts index 84f82b3254bd..f6baa6afb85c 100644 --- a/Tasks/XamariniOSV2/xamarinios.ts +++ b/Tasks/XamariniOSV2/xamarinios.ts @@ -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')); }