Skip to content

Commit

Permalink
Abort when init and run messages fail to process (#2887)
Browse files Browse the repository at this point in the history
* Abort when init and run messages fail to process, usually on deserialization, to prevent the host from hanging
* Send the message via the abort handler when we abort the run
  • Loading branch information
Haplois authored May 4, 2021
1 parent 1050e72 commit 2acc8af
Show file tree
Hide file tree
Showing 32 changed files with 379 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Testovací běh se přerušil s chybou {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Der Testlauf wurde mit dem Fehler {0} abgebrochen.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La serie de pruebas se ha anulado con el error {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Désolé... Nous n’avons pas pu procéder à la série de tests, car nous avons rencontré l’erreur suivante : {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Esecuzione dei test interrotta con errore {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[テストの実行がエラー {0} により中止されました。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[테스트 실행이 {0} 오류로 인해 중단되었습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Przebieg testowy został przerwany z powodu błędu {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Execução de Teste Abortada com Erro {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Тестовый запуск прерван с ошибкой {0}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunFailed" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Failed.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Test Çalıştırması {0} hatasıyla durduruldu.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[测试运行已中止,出现错误 {0}。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunAbortedWithError" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Aborted with error {0}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[測試執行已中止,錯誤 {0}。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";TestRunCanceled" ItemType="0" PsrId="308" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Test Run Canceled.]]></Val>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ private Assembly CurrentDomainAssemblyResolve(object sender, AssemblyResolveEven
{
try
{
EqtTrace.Verbose("CurrentDomain_AssemblyResolve: Resolving assembly '{0}'.", args.Name);
EqtTrace.Verbose("CurrentDomainAssemblyResolve: Resolving assembly '{0}'.", args.Name);

if (this.resolvedAssemblies.TryGetValue(args.Name, out assembly))
{
Expand Down
11 changes: 10 additions & 1 deletion src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private Assembly OnResolve(object sender, AssemblyResolveEventArgs args)

if (this.searchDirectories == null || this.searchDirectories.Count == 0)
{
EqtTrace.Info("AssemblyResolver.OnResolve: {0}: There are no search directories, returning.", args.Name);
return null;
}

Expand Down Expand Up @@ -146,23 +147,31 @@ private Assembly OnResolve(object sender, AssemblyResolveEventArgs args)
continue;
}

EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Searching in: '{1}'.", args.Name, dir);

foreach (var extension in SupportedFileExtensions)
{
var assemblyPath = Path.Combine(dir, requestedName.Name + extension);
try
{
if (!File.Exists(assemblyPath))
{
EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Assembly path does not exist: '{1}', returning.", args.Name, assemblyPath);

continue;
}

AssemblyName foundName = this.platformAssemblyLoadContext.GetAssemblyNameFromPath(assemblyPath);

if (!this.RequestedAssemblyNameMatchesFound(requestedName, foundName))
{
EqtTrace.Info("AssemblyResolver.OnResolve: {0}: File exists but version/public key is wrong. Try next extension.", args.Name);

continue; // File exists but version/public key is wrong. Try next extension.
}

EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Loading assembly '{1}'.", args.Name, assemblyPath);

assembly = this.platformAssemblyLoadContext.LoadAssemblyFromPath(assemblyPath);
this.resolvedAssemblies[args.Name] = assembly;

Expand All @@ -172,7 +181,7 @@ private Assembly OnResolve(object sender, AssemblyResolveEventArgs args)
}
catch (FileLoadException ex)
{
EqtTrace.Info("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex);
EqtTrace.Error("AssemblyResolver.OnResolve: {0}: Failed to load assembly. Reason:{1} ", args.Name, ex);

// Re-throw FileLoadException, because this exception means that the assembly
// was found, but could not be loaded. This will allow us to report a more
Expand Down
Loading

0 comments on commit 2acc8af

Please sign in to comment.