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

use IsTextFile to respect text file convention from EmptyFiles #1388

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ Debug.WriteLine(Namer.RuntimeAndVersion);
* `type`: The class the test method exists in.
* `method`: The test method.

Any value provided in [UseDirectory](#directory) will take precedence over the value provided in `PathInfo.Directory`.

Return null to any of the values to use the standard behavior. The returned path can be relative to the directory sourceFile exists in.

`DerivePathInfo` can also be useful when deriving the storage directory on a [build server](build-server.md#custom-directory-and-file-name)
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageVersion Include="Argon" Version="0.26.0" />
<PackageVersion Include="Argon.FSharp" Version="0.26.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="DiffEngine" Version="15.6.0" />
<PackageVersion Include="DiffEngine" Version="15.7.0" />
<PackageVersion Include="Expecto" Version="10.2.1" />
<PackageVersion Include="Fixie" Version="4.1.0" />
<PackageVersion Include="Fixie.TestAdapter" Version="4.1.0" />
Expand Down
21 changes: 7 additions & 14 deletions src/Verify/Verifier/InnerVerifier_Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ async Task<List<Target>> ToTargets(

static async Task<Target> TargetFromFile(string path, string relativePath, FileScrubber? fileScrubber, Func<Stream> openStream)
{
if (!TryGetExtension(path, out var extension))
var extension = Path
.GetExtension(path)
.Replace(".", string.Empty);

if (extension.Length == 0)
{
return new(
"noextension",
openStream(),
relativePath);
extension = "noextension";
}

if (FileExtensions.IsTextExtension(extension))
if (FileExtensions.IsTextFile(path))
{
using var stream = openStream();
var builder = await stream.ReadStringBuilderWithFixedLines();
Expand All @@ -132,12 +133,4 @@ static async Task<Target> TargetFromFile(string path, string relativePath, FileS
openStream(),
relativePath);
}

static bool TryGetExtension(string path, [NotNullWhen(true)] out string? extension)
{
extension = Path
.GetExtension(path)
.Replace(".", string.Empty);
return extension.Length > 0;
}
}