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
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def escape_command(value: str) -> str:
return value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")


def neutralize(text: str) -> str:
"""Break a workflow command that leads a line, indented or not, since the runner trims leading whitespace before it parses one."""
return re.sub(r"(?m)^([ \t]*)::", r"\1: :", text)


def normalize_tfm(value: str) -> str:
"""The short folder-style name of a target framework, however a project or nuspec spells it."""
text = value.strip().lower()
Expand Down Expand Up @@ -354,7 +359,7 @@ def run(
check=False,
timeout=COMMAND_TIMEOUT_SECONDS,
)
print(result.stdout + result.stderr, end="")
print(neutralize(result.stdout + result.stderr), end="")
return result


Expand Down
11 changes: 11 additions & 0 deletions tests/test_package_consume_nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ def test_a_failure_is_an_escaped_annotation_and_a_table_row(self) -> None:
self.assertEqual(len(report.table().splitlines()), 3)


class OutputTests(unittest.TestCase):
def test_a_line_leading_workflow_command_in_child_output_is_broken(self) -> None:
out = pcn.neutralize(
"ok\n::error::forged\n ::notice::indented\nmid ::x\n::stop-commands::t"
)
self.assertFalse(any(line.lstrip().startswith("::") for line in out.splitlines()))
self.assertIn(" : :notice::indented", out)
self.assertIn("mid ::x", out)
self.assertIn(": :error::forged", out)


class PackageSelectionTests(unittest.TestCase):
def test_a_referenced_project_package_does_not_hide_the_projects_own(self) -> None:
with tempfile.TemporaryDirectory() as name:
Expand Down
Loading