-
Notifications
You must be signed in to change notification settings - Fork 323
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
Fix logging setup when running in remote #3643
Conversation
In remote scenario we can be passed path surrounded with quotes from parameters, and we should ignore those extra quotes. We should also create the full path for log, because in local run vstest.console handles that for us, and so testhost always has the full path, but in remote run the folder is not there and setting up logs fails, and nothing is logged
@@ -161,6 +161,9 @@ public static bool InitializeVerboseTrace(string customLogFile) | |||
/// <returns>Trace initialized flag.</returns> | |||
public static bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel) | |||
{ | |||
// Remove extra quotes if we get them passed on the parameter, | |||
// System.IO.File does not ingore them when checking the file existence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// System.IO.File does not ingore them when checking the file existence. | |
// System.IO.File does not ignore them when checking the file existence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
var runnlerLogFileInfo = new FileInfo(runnerLogFileName); | ||
if (!Directory.Exists(runnlerLogFileInfo.DirectoryName)) | ||
{ | ||
Directory.CreateDirectory(runnlerLogFileInfo.DirectoryName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var runnlerLogFileInfo = new FileInfo(runnerLogFileName); | |
if (!Directory.Exists(runnlerLogFileInfo.DirectoryName)) | |
{ | |
Directory.CreateDirectory(runnlerLogFileInfo.DirectoryName); | |
} | |
var runnerLogFileInfo = new FileInfo(runnerLogFileName); | |
if (!Directory.Exists(runnerLogFileInfo.DirectoryName)) | |
{ | |
Directory.CreateDirectory(runnerLogFileInfo.DirectoryName); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/azp run |
Not sure if that is just flaky. |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with 1 nit.
@@ -367,6 +367,12 @@ private static bool EnsureTraceIsInitialized() | |||
runnerLogFileName = LogFile; | |||
} | |||
|
|||
var runnerLogFileInfo = new FileInfo(runnerLogFileName); | |||
if (!Directory.Exists(runnerLogFileInfo.DirectoryName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: You could do runnerLogFileInfo.Directory.Exists
instead.
Description
In remote scenario we can be passed path surrounded with quotes from parameters, and we should ignore those extra quotes. We should also create the full path for log, because in local run vstest.console handles that for us, and so testhost always has the full path, but in remote run the folder is not there and setting up logs fails, and nothing is logged