Skip to content

Commit 7e94697

Browse files
committed
Clean up test side effects in DAP message tests
We were depending on the test run to succeed in order to create and overwrite the file; however, this was very confusing when debugging a single test while it was failing.
1 parent 0d77907 commit 7e94697

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation.
1+
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

44
using System;
@@ -127,7 +127,13 @@ private string GenerateScriptFromLoggingStatements(params string[] logStatements
127127
throw new ArgumentNullException(nameof(logStatements), "Expected at least one argument.");
128128
}
129129

130-
// Have script create/overwrite file first with `>`.
130+
// Clean up side effects from other test runs.
131+
if (File.Exists(s_testOutputPath))
132+
{
133+
File.Delete(s_testOutputPath);
134+
}
135+
136+
// Have script create file first with `>` (but don't rely on overwriting).
131137
StringBuilder builder = new StringBuilder().Append('\'').Append(logStatements[0]).Append("' > '").Append(s_testOutputPath).AppendLine("'");
132138
for (int i = 1; i < logStatements.Length; i++)
133139
{

0 commit comments

Comments
 (0)