Skip to content

Fix issue:validate tests on Windows - #49523

Open
LuckWzx wants to merge 1 commit into
iptv-org:masterfrom
LuckWzx:fix/issue-validate-tests-windows
Open

Fix issue:validate tests on Windows#49523
LuckWzx wants to merge 1 commit into
iptv-org:masterfrom
LuckWzx:fix/issue-validate-tests-windows

Conversation

@LuckWzx

@LuckWzx LuckWzx commented Aug 25, 2026

Copy link
Copy Markdown

Problem

The issue:validate tests fail on Windows: npm test reports

ENOENT: no such file or directory, open 'D:\GoLang\iptv\tests\__data__\output\logs\errors.txt'

in all three test cases (streams:add, streams:remove, streams:edit).

Root cause: the tests built a shell command and ran it with execSync:

npm run issue:validate --- --body="${body}" --labels="approved,streams:add"

On Windows, execSync executes through cmd.exe, which truncates the
--body argument at the first newline — the issue body is inherently
multiline. The script only received --body=### Stream ID and lost the
--labels option entirely (verified with a minimal repro:

["--body=### Stream ID"] was the entire argv). With no labels matching,
none of the streams:add / streams:remove / streams:edit branches run,
so the command exits with code 0 and never writes errors.txt, and the
test fails trying to read it.

This is Windows-specific: the production workflow
(.github/workflows/validate_issue.yml) passes the body through a bash
variable (--body "$RAW_BODY") on ubuntu-latest, where multiline quoted
arguments work correctly.

Changes

In tests/commands/issue/validate.test.ts:

  • Replace execSync with execFileSync, passing the multiline issue body
    and labels as an args array — no shell involved, so no quoting or
    newline truncation issues.
  • Launch the command directly via node --import tsx scripts/commands/issue/validate.ts instead of npm run.
  • Pass the test environment variables through the env option instead of
    cross-env.

Verification

  • npm test19/19 tests pass (10/10 suites), including the previously
    failing tests/commands/issue/validate.test.ts.
  • npm run lint → no errors.

Note (alternative approach)

An alternative fix would be to add a --body-file <path> option to
scripts/commands/issue/validate.ts and have the test write the body to a
temporary file. This keeps the npm run invocation pattern but changes
production code. The chosen test-only fix keeps the change minimal and has
no impact on the CLI or the GitHub Actions workflow. Happy to switch if the
maintainers prefer the other approach.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Windows-specific failures in the issue:validate test suite by avoiding shell argument parsing/quoting issues when passing multiline issue bodies to the validator command.

Changes:

  • Replace execSync (shell-based) with execFileSync using an args array to preserve multiline --body values on Windows.
  • Invoke the validator directly via node --import tsx scripts/commands/issue/validate.ts instead of npm run ....
  • Replace cross-env usage with env injection via the execFileSync options.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants