Skip to content

Modify test:sh script to accept file paths #606

Description

@williamthorsen

Problem

The test:sh script in packages/agents/package.json hardcodes its target directory:

"test:sh": "shellspec content/scripts/"

Because nothing forwards positional arguments to shellspec, callers cannot narrow a run to a specific test file. Iterating on a single test requires running the full suite or invoking shellspec directly outside the workspace script.

Context

  • shellspec accepts [files or directories...] as positional arguments. Passing one or more file paths runs just those files; passing nothing falls back to discovery via .shellspec (--pattern "*_test.sh" against the current directory).
  • Test files live under packages/agents/content/scripts/__tests__/ (e.g., get_ticket_id_test.sh).
  • The script is invoked from the monorepo root via pnpm --filter @codeassembly/agents test:sh, with -- separating pnpm args from forwarded args.

Solution

Update the test:sh script to forward positional arguments when supplied and fall back to the current directory target when not, using POSIX default-value parameter expansion:

"test:sh": "shellspec \"${@:-content/scripts/}\""

This preserves the existing zero-argument behavior and enables targeted invocations such as:

pnpm --filter @codeassembly/agents test:sh -- content/scripts/__tests__/get_ticket_id_test.sh

Acceptance criteria

  • pnpm --filter @codeassembly/agents test:sh (no args) runs all tests under content/scripts/, matching today's behavior.
  • pnpm --filter @codeassembly/agents test:sh -- <path-to-test-file> runs only the specified test file.
  • Forwarded arguments support more than one path (e.g., two test files) and any other shellspec flags (e.g., --example).

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions