Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added exception handling while creating "TestResults" folder #2450

Merged
merged 8 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

/// <summary>
Expand Down Expand Up @@ -117,11 +118,22 @@ public void Initialize(SessionId id, string outputDirectory, IMessageSink messag
this.SessionOutputDirectory = Path.Combine(absolutePath, id.Id.ToString());
}

// Create the output directory if it doesn't exist.
if (!Directory.Exists(this.SessionOutputDirectory))
try
{
// Create the output directory if it doesn't exist.
if (!Directory.Exists(this.SessionOutputDirectory))
{
Directory.CreateDirectory(this.SessionOutputDirectory);
}
}
catch (UnauthorizedAccessException)
{
Directory.CreateDirectory(this.SessionOutputDirectory);
string currentFolderPath = Directory.GetParent(outputDirectory).FullName;
string accessDeniedMessage = string.Format(CultureInfo.CurrentCulture, Resources.Resources.AccessDenied, currentFolderPath);
ConsoleOutput.Instance.Error(false, accessDeniedMessage);
throw;
}

}

/// <inheritdoc/>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccessDenied" xml:space="preserve">
<value>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges. For more information, please look at the error message :</value>
</data>
<data name="CancellationRequested" xml:space="preserve">
<value>Cancelling the operation as requested.</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Nepovedlo se načíst rozšíření ze souboru {0}. Další informace získáte pomocí parametru /diag.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Fehler beim Laden von Erweiterungen aus der Datei "{0}". Verwenden Sie "/diag", um weitere Informationen zu erhalten.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">No se pudieron cargar las extensiones del archivo "{0}". Use /diag para obtener más información.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Le chargement des extensions à partir du fichier '{0}' a échoué. Pour plus d'informations, utilisez /diag.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Non è stato possibile caricare le estensioni dal file '{0}'. Per altre informazioni, usare /diag.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">ファイル '{0}' から拡張機能を読み込めませんでした。詳細な情報を得るには、/diag をご使用ください。</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">'{0}' 파일에서 확장을 로드하지 못했습니다. 자세한 내용을 보려면 /diag를 사용하세요.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Nie można załadować rozszerzeń z pliku „{0}”. Aby uzyskać więcej informacji, użyj opcji /diag.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Falha ao carregar as extensões do arquivo '{0}'. Use /diag para obter mais informações.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Не удалось загрузить расширения из файла "{0}". Для получения дополнительных сведений используйте /diag.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@
<target state="translated">Uzantılar '{0}' dosyasından yüklenemedi. Daha fazla bilgi için lütfen /diag kullanın.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
<trans-unit id="AccessDenied">
<source>Access denied while trying to create "TestResults" folder in {0} location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</source>
<target state="new">Access denied while trying to create "TestResults" folder in current location. You are getting this exception because you are running vstest.console.exe from a folder which requires administrator rights. To solve the issue : please open command line "As Administrator" or run vstest.console.exe from a folder where you have admin privileges.</target>
<note></note>
</trans-unit>
<trans-unit id="MoreInformation">
<source>For more information, please look at the error message :</source>
<target state="new">For more information, please look at the error message :</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Loading