-
Notifications
You must be signed in to change notification settings - Fork 235
Add support for running xUnit tests in VS Test Explorer #642
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,11 @@ protected async Task<Tuple<int, int>> LaunchService( | |
Path.Combine( | ||
Path.GetDirectoryName(assemblyPath), $"session-{++sessionCounter}.json"); | ||
|
||
if (File.Exists(sessionPath)) | ||
{ | ||
File.Delete(sessionPath); | ||
} | ||
|
||
string editorServicesModuleVersion = | ||
string.Format( | ||
"{0}.{1}.{2}", | ||
|
@@ -106,20 +111,42 @@ protected async Task<Tuple<int, int>> LaunchService( | |
// Start the process | ||
this.serviceProcess.Start(); | ||
|
||
// Wait for the server to finish initializing | ||
while (!File.Exists(sessionPath) || (new FileInfo(sessionPath).Length == 0)) | ||
string sessionDetailsText = string.Empty; | ||
|
||
// Wait up to ~5 seconds for the server to finish initializing | ||
var maxRetryAttempts = 10; | ||
while (maxRetryAttempts-- > 0) | ||
{ | ||
Thread.Sleep(100); | ||
try | ||
{ | ||
using (var stream = new FileStream(sessionPath, FileMode.Open, FileAccess.Read, FileShare.None)) | ||
using (var reader = new StreamReader(stream)) | ||
{ | ||
sessionDetailsText = reader.ReadToEnd(); | ||
break; | ||
} | ||
} | ||
catch (FileNotFoundException) | ||
{ | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.WriteLine($"Session details at '{sessionPath}' not available: {ex.Message}"); | ||
} | ||
|
||
Thread.Sleep(500); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW I timed this while loop in the debugger using VS perf tips and the time to read the file varied between about 350 ms to 1.2 secs so I figured 500 ms was a reasonable sleep time to cut down on the number of retries. |
||
} | ||
|
||
JObject result = JObject.Parse(File.ReadAllText(sessionPath)); | ||
JObject result = JObject.Parse(sessionDetailsText); | ||
if (result["status"].Value<string>() == "started") | ||
{ | ||
return new Tuple<int, int>( | ||
result["languageServicePort"].Value<int>(), | ||
result["debugServicePort"].Value<int>()); | ||
} | ||
|
||
Debug.WriteLine($"Failed to read session details from '{sessionPath}'"); | ||
|
||
return null; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This will eventually be a problem when we want to run the tests on Non-Windows because on macOS
x64
is represented asx86_64
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.
but that can be dealt with later. I see we have an Assert.StartsWith just a few lines up that mentions version 5 so we'll have to deal with that too.
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.
The PowerShellVersionDetails.Architecture property is an enum with only these values:
Unknown
,x86
,x64
. So I think it is OK represent a 64-bit macOS Architecture as x64. Besides the version number, the only other place this info is used is to send back to the extension. And it does get logged. Even the log chooses to represent the Architecture.x64 val as simply64-bit
:In this regard, I like the IntPtr.Size test better than looking at env vars.