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

Fix logging setup when running in remote #3643

Merged
merged 3 commits into from
Jun 9, 2022
Merged

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented May 16, 2022

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

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// System.IO.File does not ingore them when checking the file existence.
// System.IO.File does not ignore them when checking the file existence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 372 to 376
var runnlerLogFileInfo = new FileInfo(runnerLogFileName);
if (!Directory.Exists(runnlerLogFileInfo.DirectoryName))
{
Directory.CreateDirectory(runnlerLogFileInfo.DirectoryName);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@nohwnd
Copy link
Member Author

nohwnd commented May 16, 2022

/azp run

@nohwnd
Copy link
Member Author

nohwnd commented May 16, 2022

Not sure if that is just flaky.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Evangelink Evangelink left a 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))
Copy link
Member

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.

@nohwnd nohwnd enabled auto-merge (squash) June 9, 2022 08:40
@nohwnd nohwnd merged commit 6311e6c into microsoft:main Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants