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

Add support for running xUnit tests in VS Test Explorer #642

Merged
merged 1 commit into from Mar 23, 2018

Conversation

rkeithhill
Copy link
Collaborator

Fix issue with running xUnit tests over and over. Have a better
way to detect when the session details file has been written.

Fix issue with ServiceReturnsPowerShellVersionDetails test,
where it only worked when you ran the tests using x86 arch.
It now runs correctly using x64.

Fix issue with running xUnit tests over and over.  Have a better
way to detect when the session details file has been written.

Fix issue with ServiceReturnsPowerShellVersionDetails test,
where it only worked when you ran the tests using x86 arch.
It now runs correctly using x64.
@rkeithhill
Copy link
Collaborator Author

BTW I'm not totally sure the xunit.runner.visualstudio NuGet pkg won't interfere with running the tests on PS Core on other platforms. I figure the automatic builds will let me know. If so, I should be able to make their inclusion conditional on net452 or something like that.

@rkeithhill
Copy link
Collaborator Author

rkeithhill commented Mar 23, 2018

I still have one more xUnit test issue where it is processing my personal profile.ps1 file which modifies the prompt function. I need to figure out a fix for that.

@TylerLeonhardt
Copy link
Member

The tests, unfortunately, can only run on windows 😔 they reference powershell.exe. I wish we could get them to run on all platforms 😔

Debug.WriteLine($"Session details at '{sessionPath}' not available: {ex.Message}");
}

Thread.Sleep(500);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

LGTM :) thanks Keith!

@@ -825,7 +825,9 @@ public class LanguageServerTests : ServerTestsBase, IAsyncLifetime
Assert.StartsWith("5.", versionDetails.Version);
Assert.StartsWith("5.", versionDetails.DisplayVersion);
Assert.Equal("Desktop", versionDetails.Edition);
Assert.Equal("x86", versionDetails.Architecture);

string expectedArchitecture = (IntPtr.Size == 8) ? "x64" : "x86";
Copy link
Member

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 as x86_64

Copy link
Member

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.

Copy link
Collaborator Author

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 simply 64-bit:

        Version: Microsoft Windows NT 10.0.16299.0
        Arch:    64-bit

In this regard, I like the IntPtr.Size test better than looking at env vars.

@rkeithhill rkeithhill merged commit 1e3234c into master Mar 23, 2018
@rkeithhill rkeithhill deleted the rkeithhill/xunit-test-improvements branch March 23, 2018 21:19
TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this pull request Feb 26, 2019
* Fix detection of valid PS ext for debugging.

Was previously only allowing lower case ps1 and psm1.  I'm assuming that on *nix file systems, that PowerShell allows all variations of ps1,PS1,pS1,Ps1 as valid script extensions.

Fix PowerShell#641

* Fix issue with debugging unsaved file.

* Use same term used in the command palette.

* Shorten error message based on juneb feedback.
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.

None yet

2 participants