Skip to content

Commit c149452

Browse files
authored
Improve UpdateNanoCLRInstance (#289)
***NO_CI***
1 parent 097d83f commit c149452

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ChildProcessDebuggingSettings IsEnabled="true" xmlns="http://schemas.microsoft.com/vstudio/ChildProcessDebuggingSettings/2014">
3+
<DefaultRule EngineFilter="[inherit]" />
4+
<Rule IsEnabled="true" ProcessName="TE.ProcessHost.Managed.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
5+
<Rule IsEnabled="true" ProcessName="vstest.discoveryengine.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
6+
<Rule IsEnabled="true" ProcessName="vstest.discoveryengine.x86.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
7+
<Rule IsEnabled="true" ProcessName="vstest.executionengine.n.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
8+
<Rule IsEnabled="true" ProcessName="vstest.executionengine.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
9+
<Rule IsEnabled="true" ProcessName="vstest.executionengine.x86.exe" EngineFilter="{92ef0900-2251-11d2-b72e-0000f87572ef}" />
10+
</ChildProcessDebuggingSettings>

source/TestAdapter/NanoCLRHelper.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,29 @@ public static void UpdateNanoCLRInstance(
171171
"Upate nanoCLR instance",
172172
Settings.LoggingLevel.Verbose);
173173

174-
var arguments = "instance --update";
174+
string arguments = "instance --update";
175175

176176
if (!string.IsNullOrEmpty(clrVersion))
177177
{
178178
arguments += $" --clrversion {clrVersion}";
179179
}
180180

181-
var cmd = Cli.Wrap("nanoclr")
181+
Command cmd = Cli.Wrap("nanoclr")
182182
.WithArguments(arguments)
183183
.WithValidation(CommandResultValidation.None);
184184

185185
// setup cancellation token with a timeout of 1 minute
186186
using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)))
187187
{
188-
var cliResult = cmd.ExecuteBufferedAsync(cts.Token).Task.Result;
188+
BufferedCommandResult cliResult = cmd.ExecuteBufferedAsync(cts.Token).Task.Result;
189189

190190
if (cliResult.ExitCode == 0)
191191
{
192192
// this will be either (on update):
193193
// Updated to v1.8.1.102
194194
// or (on same version):
195195
// Already at v1.8.1.102
196-
var regexResult = Regex.Match(cliResult.StandardOutput, @"((?>v)(?'version'\d+\.\d+\.\d+\.\d+))");
196+
Match regexResult = Regex.Match(cliResult.StandardOutput, @"((?>v)(?'version'\d+\.\d+\.\d+\.\d+))");
197197

198198
if (regexResult.Success)
199199
{
@@ -203,17 +203,24 @@ public static void UpdateNanoCLRInstance(
203203
}
204204
else
205205
{
206-
logger.LogPanicMessage($"*** Failed to update nanoCLR instance ***");
206+
LogUpdateFailure(logger, cliResult);
207207
}
208208
}
209209
else
210210
{
211-
logger.LogMessage(
212-
$"Failed to update nanoCLR instance. Exit code {cliResult.ExitCode}.",
213-
Settings.LoggingLevel.Detailed);
211+
LogUpdateFailure(logger, cliResult);
214212
}
215213
}
216214
}
215+
216+
private static void LogUpdateFailure(
217+
LogMessenger logger,
218+
BufferedCommandResult cliResult)
219+
{
220+
logger.LogPanicMessage($"*** Failed to update nanoCLR instance ***");
221+
logger.LogPanicMessage($"\r\nExit code {cliResult.ExitCode}. \r\nOutput: {Environment.NewLine} {cliResult.StandardOutput}");
222+
}
223+
217224
internal class NuGetPackage
218225
{
219226
public string[] Versions { get; set; }

source/TestAdapter/Properties/launchSettings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"nanoFramework.TestAdapter": {
44
"commandName": "Executable",
55
"executablePath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe",
6-
"commandLineArgs": "E:\\GitHub\\nf-nanoFramework.TestFramework\\poc\\TestOfTestFramework\\bin\\Debug\\NFUnitTest.dll /Settings:E:\\GitHub\\nf-nanoFramework.TestFramework\\poc\\.runsettings /TestAdapterPath:."
6+
"commandLineArgs": "E:\\GitHub\\nf-nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\bin\\Debug\\NFUnitTest.dll /Settings:E:\\GitHub\\nf-nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\nano.runsettings /TestAdapterPath:E:\\GitHub\\nf-nanoFramework.TestFramework\\source\\TestAdapter\\bin\\Debug\\net48",
7+
"workingDirectory": "E:\\GitHub\\nf-nanoFramework.TestFramework\\source\\TestAdapter\\bin\\Debug\\net48",
78
},
89
"nanoFramework.TestAdapter Enterprise": {
910
"commandName": "Executable",
1011
"executablePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe",
11-
"commandLineArgs": "C:\\Repos\\nanoFramework\\lib-CoreLibrary\\nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\bin\\Debug\\NFUnitTest.dll /Settings:C:\\Repos\\nanoFramework\\lib-CoreLibrary\\nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\.runsettings /TestAdapterPath:."
12+
"commandLineArgs": "C:\\Repos\\nanoFramework\\lib-CoreLibrary\\nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\bin\\Debug\\NFUnitTest.dll /Settings:C:\\Repos\\nanoFramework\\lib-CoreLibrary\\nanoFramework.TestFramework\\poc\\TestOfTestFrameworkByReference\\.runsettings /TestAdapterPath:.",
1213
}
1314
}
1415
}

0 commit comments

Comments
 (0)