Skip to content

pt: make the Sparrowhawk test scripts runnable - #515

Open
VitorAMJorge wants to merge 1 commit into
NVIDIA:mainfrom
VitorAMJorge:pt-sparrowhawk-test-script
Open

VitorAMJorge wants to merge 1 commit into
NVIDIA:mainfrom
VitorAMJorge:pt-sparrowhawk-test-script

Conversation

@VitorAMJorge

@VitorAMJorge VitorAMJorge commented Oct 23, 2026 •

Copy link
Copy Markdown

What does this PR do ?

Make the pt Sparrowhawk test scripts runnable. Fixes #514.

  • ITN: PROJECT_DIR defaulted to /workspace/tests/en, but the script builds $PROJECT_DIR/pt/... and $PROJECT_DIR/../shunit2, so it failed before running any test. Default it to /workspace/tests, as the pt TN script already does.
  • ITN and TN: add shift $# before sourcing shUnit2, as the English scripts do. Without it, calling a script with its optional <grammars_dir> <tests_root> arguments makes shUnit2 treat them as a test file and test names. (The TN script already ran without arguments; this fixes the with-arguments case.)

Test scripts only, no grammar change.

Tests (Sparrowhawk container, grammars exported from this branch):

  • ITN: 11/11 test groups, TN: 10/10, with and without arguments
  • On main: ITN fails with shunit2: No such file or directory; TN with arguments runs 1 bogus test
  • pt pytest: 640 passed

After that comes the checklist from the repo template. Items that don't apply to a shell-script change (no new folders, Python files or language) are ticked, and the CodeQL and "new feature" items are left unticked.

Changes from the old draft:
- It's about half the length. I cut the `#!/bin/sh` paragraph and the note about later PRs.
- It now says the TN change is for the with-arguments case.
- The test results are from this session.

# AI Usage
Claude Opus 5.5 caught the bug and proposed a small fix, which I reviewed and revised. The fix aligns the pt scripts with the other Sparrowhawk test scripts: the ITN script now uses the same tests-root default for `PROJECT_DIR` as the pt TN script, and both clear their arguments with `shift $#` before loading shUnit2, as the English scripts do, so shUnit2 doesn't misread them.

tests/nemo_text_processing/pt/test_sparrowhawk_inverse_text_normalization.sh
could not run in the sparrowhawk container (docker/launch.sh, which
tools/text_processing_deployment/export_grammars.sh --MODE=test starts,
as CONTRIBUTING.md describes):

- PROJECT_DIR defaulted to /workspace/tests/en, while every test case path
  is $PROJECT_DIR/pt/..., and shUnit2 is loaded from $PROJECT_DIR/../shunit2.
  Default it to /workspace/tests, which resolves both. The second argument,
  when given, is that tests root (not the language directory).
- Arguments were not cleared before loading shUnit2, which then took them
  for test names when the script is called with arguments. Clear them
  before loading shUnit2, as the English scripts do.

The pt TN script, test_sparrowhawk_normalization.sh, already had the right
default but not the shift; it gets the same two lines.

With these, the ITN script passes all 11 test groups and the TN script all
10 on main ("Ran 11 tests. OK" / "Ran 10 tests. OK"), also when called with
the grammar directory and the tests root as arguments. Other languages'
scripts (fr, ru, sv, vi, zh, hy, es_en) share the PROJECT_DIR default and
are not changed here. These scripts declare #!/bin/sh but use bash
features, as most of the repo's Sparrowhawk scripts do; they are run with
bash, and that is left for a separate change.

Signed-off-by: Vitor A. M. Jorge <[email protected]>
@VitorAMJorge VitorAMJorge changed the title pt: make the Sparrowhawk test scripts runnable` pt: make the Sparrowhawk test scripts runnable Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pt: Sparrowhawk ITN tests cannot run (export_grammars.sh --MODE=test fails)

1 participant