Skip to content

Commit

Permalink
Don't launch debugger window for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmihai committed Jun 16, 2021
1 parent 9cc5125 commit 529e2ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
29 changes: 16 additions & 13 deletions src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public ProjectCacheTests(ITestOutputHelper output)
{
_output = output;
_env = TestEnvironment.Create(output);
_env.DoNotLaunchDebugger();

BuildManager.ProjectCacheItems.ShouldBeEmpty();
_env.WithInvariant(new CustomConditionInvariant(() => BuildManager.ProjectCacheItems.Count == 0));
Expand Down Expand Up @@ -432,10 +433,14 @@ public void ProjectCacheByBuildParametersAndGraphBuildWorks(GraphCacheResponse t
var graph = testData.CreateGraph(_env);
var mockCache = new InstanceMockCache(testData);

buildParameters.ProjectCacheDescriptor = ProjectCacheDescriptor.FromInstance(
// Reset the environment variables stored in the build params to take into account TestEnvironmentChanges.
buildParameters = new BuildParameters(buildParameters, resetEnvironment: true)
{
ProjectCacheDescriptor = ProjectCacheDescriptor.FromInstance(
mockCache,
null,
graph);
graph)
};

using var buildSession = new Helpers.BuildManagerSession(_env, buildParameters);

Expand Down Expand Up @@ -471,7 +476,12 @@ public void ProjectCacheByBuildParametersAndBottomUpBuildWorks(GraphCacheRespons
null,
graph);

buildParameters.ProjectCacheDescriptor = projectCacheDescriptor;
// Reset the environment variables stored in the build params to take into account TestEnvironmentChanges.
buildParameters = new BuildParameters(buildParameters, resetEnvironment: true)
{
ProjectCacheDescriptor = projectCacheDescriptor
};


using var buildSession = new Helpers.BuildManagerSession(_env, buildParameters);
var nodesToBuildResults = new Dictionary<ProjectGraphNode, BuildResult>();
Expand Down Expand Up @@ -518,6 +528,9 @@ public void ProjectCacheByVsWorkaroundWorks(GraphCacheResponse testData, BuildPa
runningInVisualStudio: true,
visualStudioPath: currentBuildEnvironment.VisualStudioInstallRootDirectory));

// Reset the environment variables stored in the build params to take into account TestEnvironmentChanges.
buildParameters = new BuildParameters(buildParameters, resetEnvironment: true);

BuildManager.ProjectCacheItems.ShouldBeEmpty();

var graph = testData.CreateGraph(_env);
Expand Down Expand Up @@ -934,8 +947,6 @@ public void BuildFailsWhenCacheBuildResultIsWrong()
[Fact]
public void GraphBuildErrorsIfMultiplePluginsAreFound()
{
_env.DoNotLaunchDebugger();

var graph = Helpers.CreateProjectGraph(
_env,
new Dictionary<int, int[]>
Expand All @@ -960,8 +971,6 @@ public void GraphBuildErrorsIfMultiplePluginsAreFound()
[Fact]
public void GraphBuildErrorsIfNotAllNodeDefineAPlugin()
{
_env.DoNotLaunchDebugger();

var graph = Helpers.CreateProjectGraph(
_env,
dependencyEdges: new Dictionary<int, int[]>
Expand Down Expand Up @@ -1014,8 +1023,6 @@ public static IEnumerable<object[]> CacheExceptionLocationsTestData
[MemberData(nameof(CacheExceptionLocationsTestData))]
public void EngineShouldHandleExceptionsFromCachePluginViaBuildParameters(ErrorLocations errorLocations, ErrorKind errorKind)
{
_env.DoNotLaunchDebugger();

SetEnvironmentForErrorLocations(errorLocations, errorKind.ToString());

var project = _env.CreateFile("1.proj", @$"
Expand Down Expand Up @@ -1135,8 +1142,6 @@ public void EngineShouldHandleExceptionsFromCachePluginViaBuildParameters(ErrorL
[MemberData(nameof(CacheExceptionLocationsTestData))]
public void EngineShouldHandleExceptionsFromCachePluginViaGraphBuild(ErrorLocations errorLocations, ErrorKind errorKind)
{
_env.DoNotLaunchDebugger();

SetEnvironmentForErrorLocations(errorLocations, errorKind.ToString());

var graph = Helpers.CreateProjectGraph(
Expand Down Expand Up @@ -1224,8 +1229,6 @@ public void EngineShouldHandleExceptionsFromCachePluginViaGraphBuild(ErrorLocati
[Fact]
public void EndBuildShouldGetCalledOnceWhenItThrowsExceptionsFromGraphBuilds()
{
_env.DoNotLaunchDebugger();

var project = _env.CreateFile(
"1.proj",
@$"
Expand Down
8 changes: 6 additions & 2 deletions src/Build/BackEnd/BuildManager/BuildParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,19 @@ private BuildParameters(ITranslator translator)
/// <summary>
/// Copy constructor
/// </summary>
private BuildParameters(BuildParameters other)
internal BuildParameters(BuildParameters other, bool resetEnvironment = false)
{
ErrorUtilities.VerifyThrowInternalNull(other, nameof(other));

_buildId = other._buildId;
_culture = other._culture;
_defaultToolsVersion = other._defaultToolsVersion;
_enableNodeReuse = other._enableNodeReuse;
_buildProcessEnvironment = other._buildProcessEnvironment != null ? new Dictionary<string, string>(other._buildProcessEnvironment) : null;
_buildProcessEnvironment = resetEnvironment
? CommunicationsUtilities.GetEnvironmentVariables()
: other._buildProcessEnvironment != null
? new Dictionary<string, string>(other._buildProcessEnvironment)
: null;
_environmentProperties = other._environmentProperties != null ? new PropertyDictionary<ProjectPropertyInstance>(other._environmentProperties) : null;
_forwardingLoggers = other._forwardingLoggers != null ? new List<ForwardingLoggerRecord>(other._forwardingLoggers) : null;
_globalProperties = other._globalProperties != null ? new PropertyDictionary<ProjectPropertyInstance>(other._globalProperties) : null;
Expand Down

0 comments on commit 529e2ae

Please sign in to comment.