Skip to content

[WIP] Migrate to Xunit 2.0 #895

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

Closed
wants to merge 2 commits into from
Closed

[WIP] Migrate to Xunit 2.0 #895

wants to merge 2 commits into from

Conversation

nulltoken
Copy link
Member

This depends on #894.

Some things are still missing (eg. [SkippableFact]), but this reduced the time to run the full test suite from 01.41 down to 00:32 on my box. Promising!

@@ -106,7 +106,7 @@ public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string
{
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));

Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false }));
repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false });
Copy link
Member

Choose a reason for hiding this comment

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

Eh?

Copy link
Member Author

Choose a reason for hiding this comment

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

Assert.DoesNotThrow disappeared from Xunit 2.0. The rationale behind this being "No line line should throw, otherwise the test would fail". More details at xunit/xunit#188

Copy link
Contributor

Choose a reason for hiding this comment

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

What @nulltoken said - just let the test fail, don't wrap it...

@nulltoken
Copy link
Member Author

Hmmm... I haven't updated the AppVeyor build script yet which explains the failure.

However, the Travis CI failure looks more suspicious. @Therzok Any idea?

@nulltoken
Copy link
Member Author

FWIW, regarding the (current) lack of [SkippableFact], if any Xunit 2.0 wizard happen to feel in a helping mood, I've asked for some help over at StackOverFlow 🙏

@Therzok
Copy link
Member

Therzok commented Jan 3, 2015

Yeah, it's pretty simple. It's a reflection resolution issue. You need to copy the xunit dlls in the output directory of the tests.

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

What's this file doing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's installed by the test runner NuGet package

@Therzok
Copy link
Member

Therzok commented Jan 3, 2015

Also, the travis failure seems related to this.

@nulltoken
Copy link
Member Author

Also, the travis failure seems related to this.

Good 👀! From his last comment @bradwilson seems a little bit lost regarding how to fix this issue. Do you think you could lend him a hand?

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.2.1705" newVersion="1.9.2.1705" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm... This redirect looks fishy.

@Therzok
Copy link
Member

Therzok commented Jan 3, 2015

The typeload exception can occur for a variety of reasons:

  • Exe having the same name as the dll, and it chooses the exe over the dll.
  • Architecture mismatch between the application and the library. (x64 -> x86 for example)
  • Other reasons I have no idea of.

It's most likely something in the deployment step of XUnit that changed between v1 and v2.

<HintPath>..\Lib\xUnit\xunit.extensions.dll</HintPath>
<Reference Include="xunit.assert">
<HintPath>..\packages\xunit.assert.2.0.0-beta5-build2785\lib\portable-net45+aspnetcore50+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
<Private>True</Private>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this private and the rest are not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure... I'm going to drop this and see if that fails.

@nulltoken nulltoken changed the title [WIP] Migrate tpo Xunit 2.0 [WIP] Migrate to Xunit 2.0 Jan 3, 2015
@nulltoken
Copy link
Member Author

I've opened an issue in the Xunit.Net repository: How can one reimplement [SkippableFact] and [SkippableTheory] in Xunit2.0?

@nulltoken nulltoken force-pushed the ntk/xunit20 branch 3 times, most recently from 68560fd to df6f3e4 Compare January 4, 2015 18:51
@nulltoken
Copy link
Member Author

Yeah! I've succeeded in making Xunit 2.0 run on AppVeyor

@nulltoken nulltoken force-pushed the ntk/xunit20 branch 2 times, most recently from 4e439e6 to c2b0385 Compare January 4, 2015 21:54
@nulltoken
Copy link
Member Author

@FeodorFitsner Thanks a lot for making xUnit on AppVeyor such a nice experience with xunit/xunit#117 !

Running #894 (with xUnit 1.9.x) produces this build log and run in 281.340s.

Whereas, running this WIP PR (built-on top on the previous one and only making the necessary changes to switch to xUnit 2.0) produces this build log and run in 394.853s.

However, I'm slightly puzzled regarding the difference in run times. I was (foolishly?) expecting xUnit 2.0 to be actually faster, not slower.

Any idea?

@FeodorFitsner
Copy link
Contributor

@nulltoken That's a really good question. It could have been communication lags of pushing test results to real-time build console. However, I ran simple tests for xUnit 1.9.2 and 2.0.0 and they seem to be approx. equal:
xunit 1.9.2: https://ci.appveyor.com/project/FeodorFitsner/appvyr-xunit-tests
xunit 2.0.x: https://ci.appveyor.com/project/FeodorFitsner/xunit-20-tests

Build workers have the same build2785 version installed.

@dahlbyk
Copy link
Member

dahlbyk commented Jan 12, 2015

I've started hacking around at a replacement for InconclusiveIf(...): xunit/xunit#250 (comment).

@nulltoken
Copy link
Member Author

@dahlbyk 😻

@nulltoken nulltoken force-pushed the ntk/xunit20 branch 2 times, most recently from 63f6aa7 to 68f035a Compare January 17, 2015 08:08
@Therzok
Copy link
Member

Therzok commented Mar 5, 2015

mono/mono#1618

@Therzok
Copy link
Member

Therzok commented Mar 13, 2015

@nulltoken any way to trigger a master build of mono to test xunit 2 with it?

@nulltoken
Copy link
Member Author

@Therzok Would there a way to do this by patching https://github.com/libgit2/libgit2sharp/blob/vNext/CI/travis.osx.install.deps.sh ? If you find out, feel free to push to this branch.

@nulltoken
Copy link
Member Author

Temporarily requires https://www.myget.org/F/xunit/ as an additional NuGet feed. (cf. xunit/samples.xunit@70bc7e0#commitcomment-12022759)

@shiftkey
Copy link
Contributor

shiftkey commented Jul 6, 2015

@nulltoken

Temporarily requires https://www.myget.org/F/xunit/ as an additional NuGet feed

you could add a NuGet.config to the project root to codify this requirement

e.g. https://github.com/xunit/xunit/blob/master/NuGet.Config

@nulltoken
Copy link
Member Author

@shiftkey Inetresting! Any example how I could pass this config to the nuget restore command?

@shiftkey
Copy link
Contributor

shiftkey commented Jul 6, 2015

@nulltoken if you're launching it from the repository root, it should work fine as per the docs

NuGet first loads NuGet.config from the default location, then loads any file named NuGet.config starting from the root of the current drive and ending in the current directory.

Current directory is defined as:

  • Directory from which NuGet.exe is invoked (command line scenario).
  • Directory in which the current solution was loaded from (Visual Studio scenario).

But I haven't verified this behaviour so perhaps it's incorrect.

Otherwise, you can pass in the config file explicitly:

The default configuration file can be changed through -ConfigFile option. For example, "-ConfigFile c:\my.config" means using file c:\my.config instead of %APPDATA%\NuGet\NuGet.Config as the default configuraion file.

@bording
Copy link
Member

bording commented Jul 6, 2015

FYI, when I was first getting the native binaries nuget package stuff going, I had tried to add a temporary myget feed via the nuget.config, and for some reason I ran into problems getting it to restore properly on Travis builds. Instead of investigating why it wasn't working, I just put the temp package directly on nuget,org.

Anyway, it's still worth giving it a try to see if it works correctly this time.

@shiftkey
Copy link
Contributor

shiftkey commented Jul 6, 2015

FYI, when I was first getting the native binaries nuget package stuff going, I had tried to add a temporary myget feed via the nuget.config, and for some reason I ran into problems getting it to restore properly on Travis builds.

@bording interesting. Was this with or without specifying the -ConfigFile option?

@bording
Copy link
Member

bording commented Jul 6, 2015

I didn't try the -ConfigFile option at the time, since nuget restore should work without it and didn't need it on my local windows machine. I only remember it failing on the Travis builds.

@shiftkey
Copy link
Contributor

shiftkey commented Jul 6, 2015

@bording @nulltoken I think we've got enough impetus to try both options again - we should be able to see if it succeeds with either option.

@bording
Copy link
Member

bording commented Jul 6, 2015

Yes, we definitely should be able to get it working, especially since it makes sense to spend the time now.

Just wanted to make sure people were aware that it might require some tweaking to make everything play nicely together!

@shiftkey
Copy link
Contributor

shiftkey commented Jul 6, 2015

@bording 👍

@bradwilson
Copy link

@bording said:

for some reason I ran into problems getting it to restore properly on Travis builds.

Note that the file name is case sensitive on Unix systems, but not on Windows systems. It should always be named NuGet.Config if you intend to build from non-Windows machines.

@bording
Copy link
Member

bording commented Jul 7, 2015

Note that the file name is case sensitive on Unix systems, but not on Windows systems. It should always be named NuGet.Config if you intend to build from non-Windows machines.

That has to be the issue I ran into then, because I doubt I named it that way when I tried it!

@nulltoken
Copy link
Member Author

I've added a NuGet.Config file and all the packages were successfully installed.

However, we hit a failure on Travis

        xUnit.net MSBuild runner (64-bit .NET 4.0.30319.17020)
          Discovering: LibGit2Sharp.Tests
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error : System.TypeLoadException: Could not load type 'Xunit.Sdk.XunitTestFrameworkDiscoverer, xunit.execution.desktop, Version=2.1.0.3042, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'.
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at (wrapper managed-to-native) System.Type:internal_from_name (string,bool,bool)
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Type.GetType (System.String typeName, Boolean throwOnError) [0x00000] in <filename unknown>:0 
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Runtime.Remoting.ObjRef..ctor (System.String typeName, System.String uri, IChannelInfo cinfo) [0x00000] in <filename unknown>:0 
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Runtime.Remoting.Messaging.CADMessageBase.UnmarshalArgument (System.Object arg, System.Collections.ArrayList args) [0x00000] in <filename unknown>:0 
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Runtime.Remoting.Messaging.CADMethodReturnMessage.GetReturnValue (System.Collections.ArrayList args) [0x00000] in <filename unknown>:0 
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Runtime.Remoting.Messaging.MethodResponse..ctor (IMethodCallMessage msg, System.Runtime.Remoting.Messaging.CADMethodReturnMessage retmsg) [0x00000] in <filename unknown>:0 
/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild: error :   at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage (IMessage msgRequest) [0x00000] in <filename unknown>:0 
    Task "xunit" execution -- FAILED
    Done building target "Test" in project "/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild".-- FAILED
Done building project "/home/travis/build/libgit2/libgit2sharp/CI/build.msbuild".-- FAILED

AppVeyor is also complaing, but I'm unsure why

  LibGit2Sharp.Tests -> C:\projects\libgit2sharp\LibGit2Sharp.Tests\bin\Release\LibGit2Sharp.Tests.dll
  Copying file from "obj\Release\LibGit2Sharp.Tests.pdb" to "bin\Release\LibGit2Sharp.Tests.pdb".
Done Building Project "C:\projects\libgit2sharp\LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj" (default targets).
Done Building Project "C:\projects\libgit2sharp\LibGit2Sharp.sln" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:01:53.86
cov-build.exe : 405 C# compilation units (99%) are ready for analysis
At line:1 char:1
+ & cov-build.exe --dir cov-int msbuild "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (405 C# compilat...dy for analysis:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

The cov-build utility completed successfully.

Command executed with exception: 405 C# compilation units (99%) are ready for analysis

When locally ran, one of the tests started to crash. This last issue seems unrelated to this PR and may awfully reminds me of #1091

"F:\libgit2sharp\CI\build.msbuild" (default target) (1) ->
(Test target) ->
  F:\libgit2sharp\CI\build.msbuild(40,5): error : LibGit2Sharp.Tests.StashFixture.StashCallsTheCallback: System.NullReferenceException : Object reference not set to an instance of an object.

    6 Warning(s)
    1 Error(s)

@bording
Copy link
Member

bording commented Jul 7, 2015

@nulltoken Looks like that TypeLoadException might still be a mono problem with xUnit 2.0:

xunit/xunit#158

People are reporting still running into it on 4.0.2 😦

@nulltoken
Copy link
Member Author

@bording You're right. I've seen this and (sneakily 😉) left this out for @Therzok to see.

However, I'm a bit puzzled by the AppVeyor failure... The Coverity build has never caused any issue before. Disabling it seems to resolve the issue, but I'm not sure to understand what the relation with xUnit 2.0 is.

/cc @FeodorFitsner @dakshesh-coverity

Any idea?

@nulltoken nulltoken force-pushed the ntk/xunit20 branch 2 times, most recently from 59535a7 to 886ca8f Compare August 23, 2015 14:37
@nulltoken
Copy link
Member Author

@nulltoken Looks like that TypeLoadException might still be a mono problem with xUnit 2.0:

@Therzok ^^

However, I'm a bit puzzled by the AppVeyor failure... The Coverity build has never caused any issue before. Disabling it seems to resolve the issue, but I'm not sure to understand what the relation with xUnit 2.0 is.

@bradwilson f017882 passes on Windows. It's parent doesn't. Any idea?

@Therzok
Copy link
Member

Therzok commented Aug 23, 2015

@nulltoken I think mono 4.3 with -noappdomain should work.

@akoeplinger
Copy link

@Therzok Mono >= 4.2 should work even with appdomain as afaik all the bugs where fixed. You can try the weekly builds.

@bradwilson
Copy link

Right, -noappdomain should only be needed on broken Mono.

@carlosmn
Copy link
Member

We've gone with 1.9 and a 2.0 runner which works everywhere. Maybe eventually we'll want to move to 2.0 for everything, but that'd mean dropping older mono support.

@carlosmn carlosmn closed this Apr 20, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 35d6833 on ntk/xunit20 into ** on vNext**.

@bording bording deleted the ntk/xunit20 branch April 21, 2019 02:25
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.