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

Adding fix for removing old trx files in case of multiple test tasks #6615

Merged
merged 2 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions Tasks/DotNetCoreCLI/dotnetcore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export class dotNetExe {
if (enablePublishTestResults && enablePublishTestResults === true) {
this.arguments = this.arguments.concat(` --logger trx --results-directory ${resultsDirectory}`);
}

// Remove old trx files
this.removeOldTestResultFiles(resultsDirectory);

// Use empty string when no project file is specified to operate on the current directory
const projectFiles = this.getProjectFiles();
Expand Down Expand Up @@ -148,6 +151,19 @@ export class dotNetExe {
}
}

private removeOldTestResultFiles(resultsDir:string): void {
const matchingTestResultsFiles: string[] = tl.findMatch(resultsDir, '**/*.trx');
if (!matchingTestResultsFiles || matchingTestResultsFiles.length === 0) {
tl.debug("No old result files found.");
return;
}
for (const fileIndex of Object.keys(matchingTestResultsFiles)) {
const resultFile = matchingTestResultsFiles[fileIndex];
tl.rmRF(resultFile)
tl.debug("Successfuly removed: " + resultFile);
}
}

private replaceOutputArgument(modifiedOutput: string) {
var str = this.arguments;
var index = this.outputArgumentIndex;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLI/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 131,
"Minor": 132,
"Patch": 0
},
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLI/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 131,
"Minor": 132,
"Patch": 0
},
"minimumAgentVersion": "2.0.0",
Expand Down