-
Notifications
You must be signed in to change notification settings - Fork 88
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
Fix ArgumentException
when recurse is enabled and two file target specifiers generates the same file paths
#2438
Changes from 3 commits
95c979d
663b3ab
b302644
f0c13bc
da0002b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1251,6 +1251,58 @@ public void AnalyzeCommandBase_ShouldOnlyLogArtifactsWhenResultsAreFound() | |
} | ||
} | ||
|
||
[Fact] | ||
public void AnalyzeCommandBase_ShouldNotThrowException_WhenAnalyzingSameFileBasedOnTwoTargetFileSpecifiers() | ||
{ | ||
var files = new List<string> | ||
{ | ||
$@"{Environment.CurrentDirectory}\Error.dll" | ||
}; | ||
|
||
var testCases = new[] | ||
{ | ||
new | ||
{ | ||
IsMultithreaded = false | ||
}, | ||
new | ||
{ | ||
IsMultithreaded = true | ||
} | ||
}; | ||
|
||
Action action = () => | ||
{ | ||
foreach (var testCase in testCases) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
{ | ||
var resultsCachingTestCase = new ResultsCachingTestCase | ||
{ | ||
Files = files, | ||
PersistLogFileToDisk = true, | ||
FileSystem = CreateDefaultFileSystemForResultsCaching(files, generateSameInput: true) | ||
}; | ||
|
||
var options = new TestAnalyzeOptions | ||
{ | ||
TestRuleBehaviors = resultsCachingTestCase.TestRuleBehaviors, | ||
OutputFilePath = resultsCachingTestCase.PersistLogFileToDisk ? Guid.NewGuid().ToString() : null, | ||
TargetFileSpecifiers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }, | ||
Kind = new List<ResultKind> { ResultKind.Fail }, | ||
Level = new List<FailureLevel> { FailureLevel.Warning, FailureLevel.Error }, | ||
DataToInsert = new OptionallyEmittedData[] { OptionallyEmittedData.Hashes }, | ||
}; | ||
|
||
TestRule.s_testRuleBehaviors = resultsCachingTestCase.TestRuleBehaviors.AccessibleOutsideOfContextOnly(); | ||
RunAnalyzeCommand(options, | ||
resultsCachingTestCase.FileSystem, | ||
resultsCachingTestCase.ExpectedReturnCode, | ||
multithreaded: testCase.IsMultithreaded); | ||
} | ||
}; | ||
|
||
action.Should().NotThrow(); | ||
} | ||
|
||
private void AnalyzeCommandBase_ShouldGenerateSameResultsWhenRunningSingleAndMultiThread_CoyoteHelper() | ||
{ | ||
int[] scenarios = SetupScenarios(true); | ||
|
@@ -1509,7 +1561,7 @@ private static IFileSystem CreateDefaultFileSystemForResultsCaching(IList<string | |
mockFileSystem.Setup(x => x.FileReadAllText(It.Is<string>(f => f == fullyQualifiedName))).Returns(logFileContents); | ||
|
||
mockFileSystem.Setup(x => x.FileOpenRead(It.Is<string>(f => f == fullyQualifiedName))) | ||
.Returns(new MemoryStream(Encoding.UTF8.GetBytes(generateSameInput ? logFileContents : fileNameWithoutExtension))); | ||
.Returns(new NonDisposingDelegatingStream(new MemoryStream(Encoding.UTF8.GetBytes(generateSameInput ? logFileContents : fileNameWithoutExtension)))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
return mockFileSystem.Object; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--recurse
#Closed