From ce203ff272e5fec65e277156fdb2293b0c27a7f1 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 28 Jun 2019 04:10:53 -0700 Subject: [PATCH] Updating L0 for DotNetCoreCLIV2 task (#10773) * Updating L0 * Removing unnecessary imports * Review comments --- Tasks/DotNetCoreCLIV2/Tests/L0.ts | 9 ++-- Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts | 6 --- .../Tests/validateWebProject.csproj | 17 ++++++++ .../Tests/validateWebProject.ts | 42 +++++++++++++++++++ 4 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 Tasks/DotNetCoreCLIV2/Tests/validateWebProject.csproj create mode 100644 Tasks/DotNetCoreCLIV2/Tests/validateWebProject.ts diff --git a/Tasks/DotNetCoreCLIV2/Tests/L0.ts b/Tasks/DotNetCoreCLIV2/Tests/L0.ts index 4593b87c89f3..2bef4b77d2b0 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/L0.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/L0.ts @@ -314,14 +314,15 @@ describe('DotNetCoreExe Suite', function () { it('publish works with publishWebProjects option if .csproj have Microsoft.Net.Sdk.Web', (done: MochaDone) => { - process.env["__projects__"] = "havesdk*/*.csproj;"; - process.env["__publishWebProjects__"] = "true"; - let tp = path.join(__dirname, 'publishInputs.js') + process.env["__projects__"] = "validateWebProject.csproj"; + process.env["workingDirectory"] = "."; + process.env["__publishWebProject__"] = "true"; + let tp = path.join(__dirname, 'validateWebProject.js'); let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp); tr.run(); assert(tr.invokedToolCount == 1, 'should have invoked been invoked once'); - assert(tr.succeeded, 'task should have failed'); + assert(tr.succeeded, 'task should have succeeded'); done(); }) diff --git a/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts b/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts index cceffb1abb0d..2c5eab33babb 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts @@ -88,11 +88,6 @@ let a: ma.TaskLibAnswers = { "code": 1, "stdout": "not published", "stderr": "" - }, - "dotnet publish havesdk/project.csproj": { - "code": 0, - "stdout": "published", - "stderr": "" } }, "findMatch": { @@ -103,7 +98,6 @@ let a: ma.TaskLibAnswers = { "*fail*/project.json": [], "*customoutput/project.json": ["web3/project.json", "lib2/project.json"], "dummy/project.json": ["dummy/project.json"], - "havesdk*/*.csproj": ["havesdk/project.csproj"], "" : [] } }; diff --git a/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.csproj b/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.csproj new file mode 100644 index 000000000000..8fc9f6a49bc2 --- /dev/null +++ b/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp2.1 + + + + + + + + + + + + + diff --git a/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.ts b/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.ts new file mode 100644 index 000000000000..0c9044dc1f00 --- /dev/null +++ b/Tasks/DotNetCoreCLIV2/Tests/validateWebProject.ts @@ -0,0 +1,42 @@ +import ma = require('azure-pipelines-task-lib/mock-answer'); +import tmrm = require('azure-pipelines-task-lib/mock-run'); +import path = require('path'); + +let taskPath = path.join(__dirname, '..', 'dotnetcore.js'); +let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); + +tmr.setInput('command', "publish"); +tmr.setInput('projects', process.env["__projects__"]); +tmr.setInput('publishWebProjects', process.env["__publishWebProjects__"] && process.env["__publishWebProjects__"] == "true" ? "true" : "false"); +tmr.setInput('arguments', process.env["__arguments__"] ? process.env["__arguments__"] : ""); +tmr.setInput('modifyOutputPath', process.env["modifyOutput"] == "false" ? "false" : "true"); +tmr.setInput('zipAfterPublish', process.env["zipAfterPublish"] ? process.env["zipAfterPublish"] : "false"); +tmr.setInput('workingDirectory', process.env["workingDirectory"] ? process.env["workingDirectory"] : ""); + +process.env['TASK_TEST_TRACE'] = "true"; + +var projectFile = path.join(__dirname, process.env["__projects__"]); +var execCommand = "dotnet publish " + projectFile + +let a: ma.TaskLibAnswers = { + "which": { + "dotnet": "dotnet", + }, + "checkPath": { "dotnet": true }, + "exec": {}, + "findMatch": { + "**/*.csproj\n**/*.vbproj\n**/*.fsproj": [projectFile] + } +} + +a['exec'][execCommand] = { + "code": 0, + "stdout": "published", + "stderr": "" +} + +process.env["MOCK_NORMALIZE_SLASHES"] = "true"; +tmr.setAnswers(a) +tmr.registerMock('azure-pipelines-task-lib/toolrunner', require('azure-pipelines-task-lib/mock-toolrunner')); + +tmr.run(); \ No newline at end of file