-
Notifications
You must be signed in to change notification settings - Fork 899
Enable custom unit test location with standard location fallback #1035
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
namespace LibGit2Sharp.Tests.TestHelpers | ||
|
@@ -34,7 +35,7 @@ public static Credentials PrivateRepoCredentials(string url, string usernameFrom | |
|
||
public static string BuildPath() | ||
{ | ||
string tempPath; | ||
string tempPath = null; | ||
|
||
var unixPath = Type.GetType("Mono.Unix.UnixPath, Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); | ||
|
||
|
@@ -48,11 +49,24 @@ public static string BuildPath() | |
} | ||
else | ||
{ | ||
const string LibGit2TestPath = "LibGit2TestPath"; | ||
// We're running on .Net/Windows | ||
tempPath = Path.GetTempPath(); | ||
if (Environment.GetEnvironmentVariables().Contains(LibGit2TestPath)) | ||
{ | ||
Trace.TraceInformation("{0} environment variable detected", LibGit2TestPath); | ||
tempPath = Environment.GetEnvironmentVariables()[LibGit2TestPath] as String; | ||
} | ||
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. Could you please add a new line after this brace? 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. Done |
||
|
||
if (String.IsNullOrWhiteSpace(tempPath) || !Directory.Exists(tempPath)) | ||
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. I like the idea very much! And the speed bump may be very neat for contributors. How would you feel about a brief note in the README (not in the wiki) quickly explaining how to run the tests and how to leverage this neat addition? 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. Makes sense, though is it kosher to directly mention a third-party app? |
||
{ | ||
Trace.TraceInformation("Using default test path value"); | ||
tempPath = Path.GetTempPath(); | ||
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. Maybe a |
||
} | ||
} | ||
|
||
return Path.Combine(tempPath, "LibGit2Sharp-TestRepos"); | ||
string testWorkingDirectory = Path.Combine(tempPath, "LibGit2Sharp-TestRepos"); | ||
Trace.TraceInformation("Test working directory set to '{0}'", testWorkingDirectory); | ||
return testWorkingDirectory; | ||
} | ||
} | ||
} |
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.
For troubleshooting purpose, it may be worth adding a
Trace.WriteLine
call with something alongLibGit2TestPath environment variable has been detected
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.
Good call here.
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.
Cool - is this output expected to be displayed when run from the console (or from the xunit runner in Visual Studio)? Did we confirm that it is actually displayed? I am not sure where the Trace output actually goes if one didn't hook up a trace listener.
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.
@jamill There are similar calls in
DirectoryHelper
. They're being displayed in Visual Studio output window when ran through TestDriven.Net runnerThey're also intercepted by the Resharper test runners
and the VisualStudio test runner
Although in those last two cases, they're associated with the output of the first test that is ran.