Skip to content
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
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ jobs:

- run: |
if [ "${{ matrix.shell }}" == "default" ]; then
dotnet r test --verbose
dotnet r test --verbose -- --logger "trx;LogFilePrefix=${{ matrix.os }}-integration-tests"
Copy link
Owner Author

Choose a reason for hiding this comment

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

This needs to be carried over to the build job after merging, along with updating to the latest preview build.

else
dotnet r test --verbose --script-shell "${{ matrix.shell }}"
dotnet r test --verbose --script-shell "${{ matrix.shell }}" -- --logger "trx;LogFilePrefix=${{ matrix.os }}-integration-tests"
fi
shell: bash

- name: Upload test results
uses: actions/upload-artifact@v3.0.0
if: always()
with:
name: integration-test-results
path: ./.coverage/*.trx
Comment on lines +149 to +154
Copy link
Owner Author

Choose a reason for hiding this comment

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

This won't take effect until it's merged to main.


release:
if: github.event_name == 'push'

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ jobs:
name: .NET Tests
path: "*.trx"
reporter: dotnet-trx

- uses: dorny/test-reporter@v1.5.0
with:
artifact: integration-test-results
name: .NET Tests
path: "*.trx"
reporter: dotnet-trx
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"clean:bin": "dotnet rimraf **/bin **/obj",
"prebuild": "dotnet r clean",
"build": "dotnet build",
"test": "dotnet test --no-build --logger \"trx\" --results-directory \"./.coverage\"",
"test": "dotnet test --no-build --logger \"trx;LogFilePrefix=tests\" --results-directory \"./.coverage\"",
"test:31": "dotnet r test -- --framework netcoreapp3.1",
"test:5": "dotnet r test -- --framework net5.0",
"test:6": "dotnet r test -- --framework net6.0",
Expand Down
13 changes: 3 additions & 10 deletions src/ArgumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,9 @@ public static string ConcatinateCommandAndArgArrayForDisplay(

private static void EscapeSingleArg(ref ValueStringBuilder sb, ReadOnlySpan<char> arg)
{
var needsQuotes = arg.Length == 0 || ArgumentContainsWhitespace(arg);
var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg);
var isQuoted = IsSurroundedWithQuotes(arg);

if (needsQuotes)
{
sb.Append(Quote);
}
sb.Append(Quote);

for (var i = 0; i < arg.Length; ++i)
{
Expand Down Expand Up @@ -157,10 +153,7 @@ private static void EscapeSingleArg(ref ValueStringBuilder sb, ReadOnlySpan<char
}
}

if (needsQuotes)
{
sb.Append(Quote);
}
sb.Append(Quote);
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions test/ArgumentBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class ArgumentBuilderTests
[InlineData("cm \"d\"", null, "cm \"d\"")]
[InlineData("c m d", null, "c m d")]
[InlineData("c m d", new string[0], "c m d")]
[InlineData("c m d", new[] { "one", "two", "three" }, "c m d one two three")]
[InlineData("c m d", new[] { "one", "two", "three" }, "c m d \"one\" \"two\" \"three\"")]
[InlineData("c m d", new[] { "line1\nline2", "word1\tword2" }, "c m d \"line1\nline2\" \"word1\tword2\"")]
[InlineData("c m d", new[] { "with spaces" }, "c m d \"with spaces\"")]
[InlineData("c m d", new[] { @"with\backslash" }, @"c m d with\backslash")]
[InlineData("c m d", new[] { @"""quotedwith\backslash""" }, @"c m d \""quotedwith\backslash\""")]
[InlineData("c m d", new[] { @"C:\Users\" }, @"c m d C:\Users\")]
[InlineData("c m d", new[] { @"C:\Program Files\dotnet\" }, @"c m d ""C:\Program Files\dotnet\\""")]
[InlineData("c m d", new[] { @"backslash\""preceedingquote" }, @"c m d backslash\\\""preceedingquote")]
[InlineData("c m d", new[] { @"with\backslash" }, @"c m d ""with\backslash""")]
[InlineData("c m d", new[] { @"""quotedwith\backslash""" }, @"c m d ""\""quotedwith\backslash\""""")]
[InlineData("c m d", new[] { @"C:\Users\" }, @"c m d ""C:\Users\""")]
[InlineData("c m d", new[] { @"C:\Program Files\dotnet\" }, @"c m d ""C:\Program Files\dotnet\""")]
[InlineData("c m d", new[] { @"backslash\""preceedingquote" }, @"c m d ""backslash\\\""preceedingquote""")]
[InlineData("c m d", new[] { @""" hello """ }, @"c m d ""\"" hello \""""")]
public void EscapeAndConcatenateCommandAndArgArrayForProcessStart(string command, string[] args, string expected)
{
Expand Down