Skip to content

Fix resources path computation in test setup #1630

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 1 commit into from
Nov 2, 2018

Conversation

lupino3
Copy link
Contributor

@lupino3 lupino3 commented 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 #1629.

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

ethomson commented Nov 2, 2018

As you noted, this is imperfect - we might want to consider copying the entire Resources directory to the output dir so that we know where it is. I was hoping that's as simple as a few lines of msbuild, but it does not seem to be.

Anyway, I'm not in love with this but this is a strict improvement over what's there now, which I'm surprised ever worked. :D

Thanks for this!

@ethomson ethomson merged commit 8e129e5 into libgit2:master Nov 2, 2018
alex-weaver pushed a commit to alex-weaver/libgit2sharp that referenced this pull request Mar 23, 2023
Fix resources path computation in test setup
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