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

Unit test fixes for Windows #1804

Closed
wants to merge 1 commit into from

Conversation

seriouz
Copy link

@seriouz seriouz commented Feb 28, 2023

I've made some changes to the unit tests, so that they are all working with windows.
Almost all changes regarded the end-of-line problem between Windows and Linux/Mac.

@ghost ghost added the Community label Feb 28, 2023
@seriouz
Copy link
Author

seriouz commented Feb 28, 2023

@dotnet-policy-service agree

}

}
";

var expectedCode = @"
// Hack for Windows: StyleCop uses the Environment NewLine for its replacement,
Copy link
Member

Choose a reason for hiding this comment

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

Tagging @sharwell to comment on this.

@RikkiGibson
Copy link
Contributor

Windows tests runs are timing out here.

Also seeing a warning in the test project: /home/vsts/work/1/s/tests/Formatters/OrganizeImportsFormatterTests.cs(3,1): warning IDE0005: Using directive is unnecessary. [/home/vsts/work/1/s/tests/dotnet-format.UnitTests.csproj]

@JoeRobich
Copy link
Member

Not sure why these changes would be necessary.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

In general this isn't the approach we'd want to go with for normalizing the tests. I'll need to review the variety of changes individually to discuss the resolution plan.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

I suspect the author of this pull request might have not set core.autocrlf=true on a Windows machine, which would lead to expected failures. Prior to any fixes, please verify that the local configuration is correct.

@@ -86,21 +87,26 @@ void M()

int count = 5;


count = 6;
Copy link
Member

Choose a reason for hiding this comment

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

❔ Why was this added?

@@ -163,6 +169,9 @@ void M()

// Prefer using. IDISP017
["dotnet_diagnostic.IDISP017.severity"] = "error",

// We expect new line as end_of_line in this test
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"),
Copy link
Member

Choose a reason for hiding this comment

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

❔ Why was this added?

@@ -210,6 +219,9 @@ void M()

// Prefer using. IDISP017
["dotnet_diagnostic.IDISP017.severity"] = "error",

// We expect new line as end_of_line in this test
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"),
Copy link
Member

Choose a reason for hiding this comment

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

❔ Why was this added? This test has expectedCode that relies on the environment newline, and the default end_of_line value would be the same. This test wouldn't have been failing before this change, provided the user on Windows checked out the code with the required core.autocrlf=true configuration.

sb.Append("Greeter.Greet() -> void");
sb.Append(Environment.NewLine);
sb.Append("Greeter.Greeter() -> void");
var expectedPublicApi = sb.ToString();
Copy link
Member

Choose a reason for hiding this comment

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

❔ Why was this changed?

@@ -41,7 +41,7 @@ class C

var editorConfig = new Dictionary<string, string>()
{
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption(Environment.NewLine),
["end_of_line"] = EndOfLineFormatter.GetEndOfLineOption("\n"),
Copy link
Member

Choose a reason for hiding this comment

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

❔ Why was this changed? Applies to all instances of this in the file.

@JoeRobich
Copy link
Member

Closing as 9.x development has moved into the dotnet/sdk repo.

@JoeRobich JoeRobich closed this May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants