Skip to content

Commit 50b5b33

Browse files
authored
Added new exception handling (#2461)
* Test space added * Exception handler was added to catch AccessDeniedException while trying to create TestResults folder * Remove unnecessary space * Deleted unnecessary test. Changed console message and corrected folder path in that message * Remove unnecessary dot * Removed unnecessary lines and usings and coreccted exception message * Removed unnecessary line * Updating resource files * New exception handling was added * Formatted exception message
1 parent 0f37872 commit 50b5b33

17 files changed

Lines changed: 89 additions & 2 deletions

src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ private bool RunTestInternalWithExecutors(IEnumerable<Tuple<Uri, string>> execut
458458
var exceptionsHitDuringRunTests = false;
459459
var executorsFromDeprecatedLocations = false;
460460
double totalTimeTakenByAdapters = 0;
461+
461462
foreach (var executorUriExtensionTuple in executorUriExtensionMap)
462463
{
463464
// Get the executor from the cache.
@@ -530,7 +531,11 @@ private bool RunTestInternalWithExecutors(IEnumerable<Tuple<Uri, string>> execut
530531
totalTimeTakenByAdapters += totalTimeTaken.TotalSeconds;
531532
}
532533
catch (Exception e)
533-
{
534+
{
535+
string exceptionMessage = (e is UnauthorizedAccessException)
536+
? string.Format(CultureInfo.CurrentCulture, CrossPlatEngineResources.AccessDenied, e.Message)
537+
: ExceptionUtilities.GetExceptionMessage(e);
538+
534539
exceptionsHitDuringRunTests = true;
535540

536541
if (EqtTrace.IsErrorEnabled)
@@ -547,7 +552,7 @@ private bool RunTestInternalWithExecutors(IEnumerable<Tuple<Uri, string>> execut
547552
CultureInfo.CurrentCulture,
548553
CrossPlatEngineResources.ExceptionFromRunTests,
549554
executorUriExtensionTuple.Item1,
550-
ExceptionUtilities.GetExceptionMessage(e)));
555+
exceptionMessage));
551556
}
552557
finally
553558
{

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,7 @@
201201
<data name="AttachDebuggerToDefaultTestHostFailure" xml:space="preserve">
202202
<value>Cannot attach the debugger to the default test host with process ID: {0}.</value>
203203
</data>
204+
<data name="AccessDenied" xml:space="preserve">
205+
<value>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</value>
206+
</data>
204207
</root>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">Ladicí program se nedá připojit k výchozímu hostiteli testů s ID procesu {0}.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">Der Debugger kann nicht an den Standardtesthost mit der Prozess-ID {0} angefügt werden.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">No se puede asociar el depurador al host de prueba predeterminado con el id. de proceso: {0}.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">Impossible d'attacher le débogueur à l'hôte de test par défaut ayant l'ID de processus : {0}.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">Non è possibile collegare il debugger all'host di test predefinito con ID processo {0}.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">デバッガーをプロセス ID: {0} の既定のテスト ホストにアタッチできません。</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

src/Microsoft.TestPlatform.CrossPlatEngine/Resources/xlf/Resources.ko.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@
212212
<target state="translated">프로세스 ID가 {0}인 기본 테스트 호스트에 디버거를 연결할 수 없습니다.</target>
213213
<note></note>
214214
</trans-unit>
215+
<trans-unit id="AccessDenied">
216+
<source>{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges.</source>
217+
<target state="new">{0} Access denied while trying to create "TestResults" folder in mentioned location. You are getting this exception because you are running vstest.console.exe from a folder which requires having write access. To solve the issue: please run vstest.console.exe from a folder where you have write privileges. For more information, please look at the error message:</target>
218+
<note></note>
219+
</trans-unit>
215220
</body>
216221
</file>
217222
</xliff>

0 commit comments

Comments
 (0)