Skip to content
Prev Previous commit
Next Next commit
Look for tar in PATH on all OSes
  • Loading branch information
jozkee committed Sep 7, 2022
commit 99a7381de3472d4477b861793eb53ca14210aaf0
4 changes: 2 additions & 2 deletions src/libraries/System.Formats.Tar/tests/TarTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public static IEnumerable<object[]> GetPaxAndGnuTestCaseNames()
private static bool CanExtractWithTarTool_Method()
{
using Process tarToolProcess = new Process();
tarToolProcess.StartInfo.FileName = OperatingSystem.IsWindows() ? "tar" : "/usr/bin/tar";
tarToolProcess.StartInfo.FileName = "tar"; // location varies: find it on the PATH.
tarToolProcess.StartInfo.Arguments = "--help";

tarToolProcess.StartInfo.RedirectStandardOutput = true;
Expand All @@ -633,7 +633,7 @@ private static bool CanExtractWithTarTool_Method()
public static void ExtractWithTarTool(string source, string destination)
{
using Process tarToolProcess = new Process();
tarToolProcess.StartInfo.FileName = OperatingSystem.IsWindows() ? "tar" : "/usr/bin/tar";
tarToolProcess.StartInfo.FileName = "tar"; // location varies: find it on the PATH.
tarToolProcess.StartInfo.Arguments = $"-xf {source} -C {destination}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an additional boolean parameter isCompressed to this ExtractWithTarTool method. If true, then the arguments could include the z letter, which is used to extract *.tar.gz files.

We would just have to adjust line 271 of the ResultingArchive_CanBeExtractedByOtherTools test method, so that it takes a variable CompressionMethod.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that should be part of the TODOs about adding more variants of this test.


tarToolProcess.StartInfo.RedirectStandardOutput = true;
Expand Down