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

Some minor test baseline fixes #25424

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class TestSqlLoggerFactory : ListLoggerFactory

private static readonly string _eol = Environment.NewLine;

private static object _queryBaselineFileLock = new();

public TestSqlLoggerFactory()
: this(_ => true)
{
Expand Down Expand Up @@ -85,7 +87,9 @@ public void AssertBaseline(string[] expected, bool assertOrder = true)
var currentDirectory = Directory.GetCurrentDirectory();
var logFile = currentDirectory.Substring(
0,
currentDirectory.LastIndexOf("\\artifacts\\", StringComparison.Ordinal) + 1)
currentDirectory.LastIndexOf(
$"{Path.DirectorySeparatorChar}artifacts{Path.DirectorySeparatorChar}",
StringComparison.Ordinal) + 1)
+ "QueryBaseline.txt";

var testInfo = testName + " : " + lineNumber + FileNewLine;
Expand All @@ -106,7 +110,10 @@ public void AssertBaseline(string[] expected, bool assertOrder = true)

var contents = testInfo + newBaseLine + FileNewLine + "--------------------" + FileNewLine;

File.AppendAllText(logFile, contents);
lock (_queryBaselineFileLock)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows locks files by default, but other platforms don't, so concurrent tests could step over each other here

{
File.AppendAllText(logFile, contents);
}

throw;
}
Expand Down