-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Log environment-derived properties #7484
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
Changes from 15 commits
c7e5c0a
418b210
fb96241
cf9c722
d7c03b2
5b58243
fdee113
be584ed
16332a7
2a749b8
150a442
dfe55d7
bb51b1f
133f760
775a20d
2fc3b00
4c0f001
30cb0e1
d13ef44
01d3362
75dc9dd
7914d87
47d80f6
fff4f97
9fb427c
0b830e5
c2b93b9
d1cad7b
d4c2f06
add1258
679c003
aa46661
ce8dad4
01ee110
ad92323
0316ba7
44aa9b6
f7ccf3d
22525b6
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 |
|---|---|---|
|
|
@@ -4531,7 +4531,9 @@ public void VerifyPropertyTrackingLoggingDefault() | |
| logger | ||
| .AllBuildEvents | ||
| .OfType<EnvironmentVariableReadEventArgs>() | ||
| .ShouldBeEmpty(); | ||
| .ShouldHaveSingleItem() | ||
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
Member
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. Update comment on line 4521 (and similar) please.
Contributor
Author
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. I just saw one comment to update—were you thinking I should add more, or was that all?
Member
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. If that's the only comment about empty environment, it's all we need. I think I thought there were others in other test cases? |
||
|
|
||
| logger | ||
| .AllBuildEvents | ||
|
|
@@ -4560,7 +4562,9 @@ public void VerifyPropertyTrackingLoggingPropertyReassignment() | |
| logger | ||
| .AllBuildEvents | ||
| .OfType<EnvironmentVariableReadEventArgs>() | ||
| .ShouldBeEmpty(); | ||
| .ShouldHaveSingleItem() | ||
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
|
|
@@ -4589,7 +4593,9 @@ public void VerifyPropertyTrackingLoggingNone() | |
| logger | ||
| .AllBuildEvents | ||
| .OfType<EnvironmentVariableReadEventArgs>() | ||
| .ShouldBeEmpty(); | ||
| .ShouldHaveSingleItem() | ||
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
|
|
@@ -4618,7 +4624,9 @@ public void VerifyPropertyTrackingLoggingPropertyInitialValue() | |
| logger | ||
| .AllBuildEvents | ||
| .OfType<EnvironmentVariableReadEventArgs>() | ||
| .ShouldBeEmpty(); | ||
| .ShouldHaveSingleItem() | ||
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
|
|
@@ -4702,7 +4710,9 @@ public void VerifyPropertyTrackingLoggingUninitializedPropertyRead() | |
| logger | ||
| .AllBuildEvents | ||
| .OfType<EnvironmentVariableReadEventArgs>() | ||
| .ShouldBeEmpty(); | ||
| .ShouldHaveSingleItem() | ||
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Xunit.Abstractions; | ||
| using Shouldly; | ||
|
|
||
| #nullable disable | ||
|
|
||
|
|
@@ -80,54 +81,42 @@ public UtilitiesTestReadOnlyLoad() | |
| [Fact] | ||
| public void CommentsInPreprocessing() | ||
| { | ||
| Microsoft.Build.Construction.XmlDocumentWithLocation.ClearReadOnlyFlags_UnitTestsOnly(); | ||
|
|
||
| string input = FileUtilities.GetTemporaryFile(); | ||
| string output = FileUtilities.GetTemporaryFile(); | ||
|
|
||
| string _initialLoadFilesWriteable = Environment.GetEnvironmentVariable("MSBUILDLOADALLFILESASWRITEABLE"); | ||
| try | ||
| using (TestEnvironment env = TestEnvironment.Create()) | ||
|
||
| { | ||
| Environment.SetEnvironmentVariable("MSBUILDLOADALLFILESASWRITEABLE", "1"); | ||
| XmlDocumentWithLocation.ClearReadOnlyFlags_UnitTestsOnly(); | ||
|
|
||
| string content = ObjectModelHelpers.CleanupFileContents(@" | ||
| <Project DefaultTargets='Build' ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'> | ||
| TransientTestFile inputFile = env.CreateFile("tempInput.tmp", ObjectModelHelpers.CleanupFileContents(@" | ||
| <Project DefaultTargets='Build'> | ||
| <Import Project='$(MSBuildToolsPath)\Microsoft.CSharp.targets'/> | ||
| </Project>"); | ||
| File.WriteAllText(input, content); | ||
| </Project>")); | ||
| TransientTestFile outputFile = env.CreateFile("tempOutput.tmp"); | ||
|
|
||
| env.SetEnvironmentVariable("MSBUILDLOADALLFILESASWRITEABLE", "1"); | ||
|
|
||
| #if FEATURE_GET_COMMANDLINE | ||
| Assert.Equal(MSBuildApp.ExitType.Success, MSBuildApp.Execute(@"c:\bin\msbuild.exe """ + input + | ||
| (NativeMethodsShared.IsUnixLike ? @""" -pp:""" : @""" /pp:""") + output + @"""")); | ||
| MSBuildApp.Execute(@"c:\bin\msbuild.exe """ + inputFile.Path + | ||
| (NativeMethodsShared.IsUnixLike ? @""" -pp:""" : @""" /pp:""") + outputFile.Path + @"""") | ||
| .ShouldBe(MSBuildApp.ExitType.Success); | ||
| #else | ||
| Assert.Equal( | ||
| MSBuildApp.ExitType.Success, | ||
| MSBuildApp.Execute( | ||
| new[] { @"c:\bin\msbuild.exe", '"' + input + '"', | ||
| '"' + (NativeMethodsShared.IsUnixLike ? "-pp:" : "/pp:") + output + '"'})); | ||
| new[] { @"c:\bin\msbuild.exe", '"' + inputFile.Path + '"', | ||
| '"' + (NativeMethodsShared.IsUnixLike ? "-pp:" : "/pp:") + outputFile.Path + '"'})); | ||
| #endif | ||
|
|
||
| bool foundDoNotModify = false; | ||
| foreach (string line in File.ReadLines(output)) | ||
| foreach (string line in File.ReadLines(outputFile.Path)) | ||
| { | ||
| if (line.Contains("<!---->")) // This is what it will look like if we're loading read/only | ||
| { | ||
| Assert.True(false); | ||
| } | ||
| line.ShouldNotContain("<!---->", "This is what it will look like if we're loading read/only"); | ||
|
|
||
| if (line.Contains("DO NOT MODIFY")) // this is in a comment in our targets | ||
| { | ||
| foundDoNotModify = true; | ||
| } | ||
| } | ||
|
|
||
| Assert.True(foundDoNotModify); | ||
| } | ||
| finally | ||
| { | ||
| File.Delete(input); | ||
| File.Delete(output); | ||
| Environment.SetEnvironmentVariable("MSBUILDLOADALLFILESASWRITEABLE", _initialLoadFilesWriteable); | ||
| foundDoNotModify.ShouldBeTrue(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.