Skip to content

CLI entry point (bin/binary_sdk_bridge.dart) has zero test coverage #10

Description

@saimskywalker

Problem

bin/binary_sdk_bridge.dart is the primary user-facing surface — it does argument parsing, defensive numeric parsing with custom error messages, flavor validation, --dry-run output, --force/overwrite error handling, and the final "Next steps" message — but it is not covered by any test, and it is not part of the coverage report the repo already generates. All existing tests in test/generator_test.dart exercise BridgeSpec/BridgeGenerator directly, never the CLI's main().

Evidence

  • coverage/lcov.info lists SF: entries only for lib/src/generator.dart, lib/src/spec.dart, and the three lib/src/templates/*.dart files — there is no SF:.../bin/binary_sdk_bridge.dart entry anywhere in the file, confirming it is excluded from coverage entirely (grep -n "^SF:" coverage/lcov.info).
  • grep -rn for the CLI's own file across test/ returns nothing; test/generator_test.dart never imports or shells out to bin/binary_sdk_bridge.dart.
  • .github/workflows/ci.yml's "Generated output is valid" step (lines 27-49) does invoke the CLI (dart run bin/binary_sdk_bridge.dart ...), but only on the happy path with fully-valid arguments — it asserts nothing about the CLI's own behavior (exit codes, error text, --dry-run listing format).
  • Concretely untested code paths in bin/binary_sdk_bridge.dart:
    • _fail / exit code 64 on missing --name/--org (lines 55-60) or a non-numeric --min-sdk/--compile-sdk/--java (lines 62-77).
    • The --dry-run branch (lines 106-113), which lists planned files without writing them.
    • The StateErrorexitCode = 1 path when --force is omitted and the output directory already exists (lines 115-122).
    • args.flag('help') || arguments.isEmpty printing usage (line 50-53).

Proposed fix

Add a test/cli_test.dart that invokes the CLI as a subprocess (Process.run('dart', ['run', 'bin/binary_sdk_bridge.dart', ...]), mirroring the pattern CI already uses) or, preferably, refactor main()'s body into a testable function (e.g. int run(List<String> arguments, {required Stdout out, required Stdout err})) that unit tests can call directly without spawning a process. Cover at minimum: missing required flags exits 64 with the usage text, an invalid --flavor/non-numeric flag exits 64, --dry-run lists files without touching disk, and re-running without --force on an existing directory exits 1.

Acceptance criteria

  • bin/binary_sdk_bridge.dart (or an extracted, equivalently-covered run() function) appears in coverage/lcov.info with non-trivial line coverage.
  • Tests assert the exit code and stderr/stdout content for at least the four paths listed above.
  • The new tests run as part of dart test in CI without requiring changes to .github/workflows/ci.yml's existing steps.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions