Skip to content

Commit

Permalink
expose DiffRunner.Disabled
Browse files Browse the repository at this point in the history
and dont launch by default for CI or continuous testing
  • Loading branch information
SimonCropp committed Jul 12, 2020
1 parent 1ea892c commit 2d02206
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/DiffEngine/DiffRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ public static class DiffRunner
{
static int maxInstancesToLaunch = 5;
static int launchedInstances;
internal static bool disabled;
public static bool Disabled { get; set; }

static DiffRunner()
{
Disabled = IsDisableByEnv() ||
BuildServerDetector.Detected ||
ContinuousTestingDetector.Detected;
}

static bool IsDisableByEnv()
{
var disabledVariable = Environment.GetEnvironmentVariable("DiffEngine.Disabled");
disabled = string.Equals(disabledVariable, "true", StringComparison.OrdinalIgnoreCase);
return string.Equals(disabledVariable, "true", StringComparison.OrdinalIgnoreCase);
}

public static void MaxInstancesToLaunch(int value)
Expand All @@ -31,7 +38,7 @@ public static void MaxInstancesToLaunch(int value)
/// </summary>
public static void Kill(string tempFile, string targetFile)
{
if (disabled)
if (Disabled)
{
return;
}
Expand All @@ -58,7 +65,7 @@ public static LaunchResult Launch(DiffTool tool, string tempFile, string targetF
{
GuardFiles(tempFile, targetFile);

if (disabled)
if (Disabled)
{
return LaunchResult.Disabled;
}
Expand All @@ -77,7 +84,7 @@ public static LaunchResult Launch(DiffTool tool, string tempFile, string targetF
public static LaunchResult Launch(string tempFile, string targetFile)
{
GuardFiles(tempFile, targetFile);
if (disabled)
if (Disabled)
{
return LaunchResult.Disabled;
}
Expand All @@ -96,7 +103,7 @@ public static LaunchResult Launch(ResolvedTool tool, string tempFile, string tar
{
GuardFiles(tempFile, targetFile);
Guard.AgainstNull(tool, nameof(tool));
if (disabled)
if (Disabled)
{
return LaunchResult.Disabled;
}
Expand Down
3 changes: 2 additions & 1 deletion src/DiffEngine/DiffTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public static class DiffTools

public static IEnumerable<ResolvedTool> Resolved { get => resolved; }

public static ResolvedTool? AddTool(string name,
public static ResolvedTool? AddTool(
string name,
bool autoRefresh,
bool isMdi,
bool supportsText,
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649</NoWarn>
<Version>4.1.0</Version>
<Version>4.2.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Json, Testing, Verify, Snapshot, Approvals</PackageTags>
<Description>Enables simple verification of complex models and documents.</Description>
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/DiffRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Kill()
[Fact]
public void LaunchAndKillDisabled()
{
DiffRunner.disabled = true;
DiffRunner.Disabled = true;
try
{
Assert.False(IsRunning());
Expand All @@ -55,7 +55,7 @@ public void LaunchAndKillDisabled()
}
finally
{
DiffRunner.disabled = false;
DiffRunner.Disabled = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Tests/GlobalSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public static class GlobalSetup
public static void Setup()
{
Logging.Enable();
DiffRunner.Disabled = false;
}
}

0 comments on commit 2d02206

Please sign in to comment.