Skip to content

Commit

Permalink
error management
Browse files Browse the repository at this point in the history
  • Loading branch information
olduh29 committed Jun 18, 2020
1 parent 60484a1 commit ff10e0b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { exec, execSync } = require("child_process");
const path = require('path');
var fs = require('fs');


try {
// `who-to-greet` input defined in action metadata file
const output = core.getInput('output');
Expand All @@ -21,6 +22,8 @@ try {
/**** ****/
/****************************************/

console.log("create msbuild.rsp file");

let msbuild = `/p:coverletOutput=${output} /p:CollectCoverage=true /p:CoverletOutputFormat=${outputFormat}`
if (excludes !== null && excludes !== undefined) {
msbuild += ` /:exclude="${excludes}"`;
Expand All @@ -37,8 +40,7 @@ fs.writeFileSync('msbuild.rsp',msbuild);
/* *** ****/
/* ***************************************/

var ls = execSync('ls -la');
console.log(ls.toString());
console.log("run dotnet test");

var dotnet = execSync('dotnet test -c Debug');
console.log(dotnet.toString());
Expand All @@ -50,16 +52,22 @@ console.log(dotnet.toString());
/**** ****/
/****************************************/

const coverageFile = `${path.dirName(testProject)}${path.delimiter}${testProject}\${output}`;

console.log(`delete msbuild.rsp and set coverageFile output : ${coverageFile}`);

if (fs.existsSync('msbuild.rsp')) {
core.setOutput("coverageFile", `${path.dirName(testProject)}${path.delimiter}${testProject}\${output}` );
fs.unlinkSync('msbuild.rsp')
core.setOutput("coverageFile", coverageFile );
fs.unlinkSync('msbuild.rsp');
}
else {
core.setFailed(`unable to find coverage file ${coverageFile}`);
}


} catch (error) {
if (fs.existsSync('msbuild.rsp')) {
var msbuildContent = fs.readFileSync('msbuild.rsp');
console.log(msbuildContent);
console.log(msbuildContent.toString());
core.setFailed(`error occured : ${error}`);
fs.unlinkSync('msbuild.rsp')
}
core.setFailed(error.message);
Expand Down

0 comments on commit ff10e0b

Please sign in to comment.