Skip to content

Commit

Permalink
fixing test that didn't pass on windows by improving error to return …
Browse files Browse the repository at this point in the history
…path you provided instead of resolved path.
  • Loading branch information
belav committed Mar 22, 2024
1 parent 94d238b commit 88f8193
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
11 changes: 5 additions & 6 deletions Src/CSharpier.Cli.Tests/CliTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,14 @@ public async Task Should_Format_Unicode()
result.ExitCode.Should().Be(0);
}

[Test]
public async Task Should_Print_NotFound()
[TestCase("BasicFile.cs")]
[TestCase("./BasicFile.cs")]
public async Task Should_Print_NotFound(string path)
{
var result = await new CsharpierProcess().WithArguments("/BasicFile.cs").ExecuteAsync();
var result = await new CsharpierProcess().WithArguments(path).ExecuteAsync();

result.Output.Should().BeEmpty();
result
.ErrorOutput.Should()
.StartWith("There was no file or directory found at /BasicFile.cs");
result.ErrorOutput.Should().StartWith("There was no file or directory found at " + path);
result.ExitCode.Should().Be(1);
}

Expand Down
3 changes: 2 additions & 1 deletion Src/CSharpier.Cli/CommandLineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ CancellationToken cancellationToken
if (!isFile && !isDirectory)
{
console.WriteErrorLine(
"There was no file or directory found at " + directoryOrFilePath
"There was no file or directory found at "
+ commandLineOptions.OriginalDirectoryOrFilePaths[x]
);
return 1;
}
Expand Down
9 changes: 1 addition & 8 deletions Src/CSharpier.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,7 @@ CancellationToken cancellationToken
}
else
{
directoryOrFile = directoryOrFile!
.Select(o =>
o == "."
// .csharpierignore gets confused by . so just don't include it
? Directory.GetCurrentDirectory()
: Path.GetFullPath(o)
)
.ToArray();
directoryOrFile = directoryOrFile!.Select(Path.GetFullPath).ToArray();
}

var commandLineOptions = new CommandLineOptions
Expand Down

0 comments on commit 88f8193

Please sign in to comment.