@@ -131,6 +131,13 @@ public static void Test(ParsedCommandLine commandArgs, EndpointCollection endpoi
131131 {
132132 if ( commandArgs . Diff )
133133 {
134+ var diffTool = Environment . GetEnvironmentVariable ( "DIFFTOOL" ) ;
135+ if ( diffTool == null )
136+ {
137+ Error . WriteLine ( "ERROR: No diff tool configured. Set DIFFTOOL environment variable to point to executable." ) ;
138+ return ;
139+ }
140+
134141 var testCase = testRunner . Tests . ElementAt ( index ) ;
135142 if ( testCase . ExpectedResponseBody == null )
136143 {
@@ -151,15 +158,18 @@ public static void Test(ParsedCommandLine commandArgs, EndpointCollection endpoi
151158 File . WriteAllText ( expectedFilename , testCase . ExpectedResponseBody ) ;
152159 File . WriteAllText ( actualFilename , responseTuple . Item1 ) ;
153160
154- StartExternalDiffTool ( expectedFilename , actualFilename ) ;
155- }
156- if ( commandArgs . ShowResponse )
157- {
158- testRunner . ShowResponse ( index ) ;
161+ StartExternalDiffTool ( diffTool , expectedFilename , actualFilename ) ;
159162 }
160163 else
161164 {
162- testRunner . ExecuteTestAndOutputResult ( index ) ;
165+ if ( commandArgs . ShowResponse )
166+ {
167+ testRunner . ShowResponse ( index ) ;
168+ }
169+ else
170+ {
171+ testRunner . ExecuteTestAndOutputResult ( index ) ;
172+ }
163173 }
164174 }
165175 }
@@ -185,16 +195,13 @@ public static int[] ParseOnlyArgument(string only, string[] names)
185195 }
186196 }
187197
188- public static void StartExternalDiffTool ( string expectedFilename , string actualFilename )
198+ public static void StartExternalDiffTool ( string diffTool , string expectedFilename , string actualFilename )
189199 {
190- var difftool = Environment . GetEnvironmentVariable ( "DIFFTOOL" ) ;
191- if ( difftool == null )
192- {
193- Error . WriteLine ( "ERROR: No diff tool configured. Set DIFFTOOL environment variable to point to executable." ) ;
194- return ;
195- }
196-
197- Process . Start ( difftool , $ "\" { expectedFilename } \" \" { actualFilename } \" ") ;
200+ Debug . Assert ( diffTool != null ) ;
201+ Debug . Assert ( File . Exists ( expectedFilename ) ) ;
202+ Debug . Assert ( File . Exists ( actualFilename ) ) ;
203+ WriteLine ( $ "Starting external diff tool { diffTool } ") ;
204+ Process . Start ( diffTool , $ "\" { expectedFilename } \" \" { actualFilename } \" ") ;
198205 }
199206
200207
0 commit comments