Skip to content

Tests don't run from command-line or VSCode #1629

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
lupino3 opened this issue Nov 2, 2018 · 0 comments
Closed

Tests don't run from command-line or VSCode #1629

lupino3 opened this issue Nov 2, 2018 · 0 comments

Comments

@lupino3
Copy link
Contributor

lupino3 commented Nov 2, 2018

Reproduction steps

  1. Clone the repository from the WSL command line
  2. Open the folder in Visual Studio Code
  3. Try to run one test (click on "Run Test" over any test)

Alternatively, after cloning, run dotnet restore and run any test with dotnet test, for example:

$ dotnet test LibGit2Sharp.Tests//LibGit2Sharp.Tests.csproj --filter LibGit2Sharp.Tests.UnstageFixture.CanUnstageSourceOfARename

Expected behavior

The test runs, and either passes or fails.

Actual behavior

The test always fails, cannot open the testrepo_wd directory. Example:

System.IO.DirectoryNotFoundException : Could not find a part of the path 'C:\Users\<my username>\source\github\LibGit2Sharp.Tests\Resources\testrepo_wd'.

The directory is not found because the path is wrong. It is missing the git repo name. The correct one would be:

C:\Users\<my username>\source\github\libgit2sharp\LibGit2Sharp.Tests\Resources\testrepo_wd

Note that this is fixed if the environment variable Configuration is set to release, for some reason.

Version of LibGit2Sharp (release number or SHA1)

0a9c84d (current HEAD)

Operating system(s) tested; .NET runtime tested

Windows 10 Enterprise 1803
.NET Core 2.1.403

lupino3 added a commit to lupino3/libgit2sharp that referenced this issue Nov 2, 2018
The resources path is set based on the path of the current assembly.

The problem is that the assembly directory has a different number of
components, depending on whether the Configuration environment variable
is set or not.

Therefore, the previous code, that depended on the number of subdirs,
would fail if there is no value for the Configuration environment
variable.

The new code looks for the occurrence of a well-known string in the path
and bases the path of the test resources off that position.

It is still pretty sub-optimal, but I think it's a bit less sub-optimal
than it was.

Tested in the following ways:
- run dotnet test on one test from the command line on Windows;
- click on "Run Test" from Visual Studio Code.

Fixes libgit2#1629.
alex-weaver pushed a commit to alex-weaver/libgit2sharp that referenced this issue Mar 23, 2023
The resources path is set based on the path of the current assembly.

The problem is that the assembly directory has a different number of
components, depending on whether the Configuration environment variable
is set or not.

Therefore, the previous code, that depended on the number of subdirs,
would fail if there is no value for the Configuration environment
variable.

The new code looks for the occurrence of a well-known string in the path
and bases the path of the test resources off that position.

It is still pretty sub-optimal, but I think it's a bit less sub-optimal
than it was.

Tested in the following ways:
- run dotnet test on one test from the command line on Windows;
- click on "Run Test" from Visual Studio Code.

Fixes libgit2#1629.
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

No branches or pull requests

1 participant