Skip to content

Conversation

ascandone
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Caution

Review failed

Failed to post review comments

Walkthrough

Adds a new CLI subcommand to initialize test specs from a NumScript file, refactors test command argument handling, extends specs/test format with focus/skip, postings, and end-balance expectations (including subset checks), updates runner UI and skip logic, introduces map-include utilities, and adds a balance-inclusion comparator with tests.

Changes

Cohort / File(s) Summary
CLI Commands
internal/cmd/root.go, internal/cmd/test.go, internal/cmd/test_init.go
Registers a new test-init subcommand; refactors test command to pass args explicitly; implements test-init command to parse NumScript, generate default vars, run program against a simple store, and write a .specs.json file.
Interpreter Balances
internal/interpreter/balances.go, internal/interpreter/balances_test.go
Adds CompareBalancesIncluding for subset balance checks; adds tests covering inclusion, value differences, and extras.
Specs Core and Tests
internal/specs_format/index.go, internal/specs_format/run_test.go, internal/specs_format/runner.go, internal/specs_format/runner_test.go
Extends Specs/TestCase/TestCaseResult with schema, focus/skip, postings, end-balance expectations (exact and include), error key changes; introduces skip/focus handling in Check; updates runner output and stats; adjusts/extends tests accordingly.
Utils
internal/utils/utils.go
Adds MapIncludes and updates MapCmp to use inclusion logic; enables nested map equality via Map2Cmp delegating to MapCmp.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant CLI as test-init CLI
  participant FS as File System
  participant P as Parser
  participant IR as Interpreter
  participant S as TestInitStore

  U->>CLI: run test-init <path/to/script.ns>
  CLI->>FS: Read NumScript file
  CLI->>P: Parse program
  P-->>CLI: AST or parse error
  alt parse error
    CLI-->>U: Print error and exit(1)
  else parsed
    CLI->>CLI: Extract vars, mkDefaultVar(...)
    CLI->>IR: RunProgram(AST, S)
    IR-->>CLI: Result (postings) or runtime error
    alt runtime error
      CLI-->>U: Panic/abort (iErr)
    else success
      CLI->>CLI: Build Specs{schema, balances, vars, tests}
      CLI->>FS: Write <script>.specs.json
      CLI-->>U: Print success message
    end
  end
Loading
sequenceDiagram
  autonumber
  participant SF as SpecsFormat.Check
  participant TC as TestCase loop
  participant IR as Interpreter
  participant CMP as Balance Comparators

  SF->>TC: Pre-scan tests for Focus
  loop For each test
    alt Focus exists and test not focused
      TC-->>SF: Mark Skipped
    else Run
      TC->>IR: Execute program
      IR-->>TC: Result (postings, balances/meta)
      alt Expect endBalances
        TC->>CMP: CompareBalances (exact)
        CMP-->>TC: bool
      end
      alt Expect endBalances.include
        TC->>CMP: CompareBalancesIncluding (subset)
        CMP-->>TC: bool
      end
      TC-->>SF: Record pass/fail with postings
    end
  end
  SF-->>SF: Aggregate passed/failed/skipped counts
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • feat: improve testing tool #93 — Mirrors these changes: inclusion balance compare, map include utilities, specs focus/skip/postings, and runner updates.
  • feat: specs format #70 — Related CLI/specs refactors impacting test command, specs_format, utils, and interpreter balances.

Suggested reviewers

  • gfyrag
  • Quentin-David-24
  • laouji

Poem

A rabbit taps keys in a moonlit glade,
New specs hatch where NumScript is played.
Focus or skip? We mark the way—
Postings hop out, end balances stay.
Maps include, not just compare—
Thump! Green checks dance through the air. 🐇✨

Pre-merge checks and finishing touches and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is empty and does not describe any part of the changes made, leaving reviewers without context on the purpose and scope of the update. Please provide a description summarizing the purpose of the changes, such as the addition of the test init command and related refactorings.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “feat: test init” succinctly captures the primary change of adding the test init feature without extra noise or ambiguity, making it clear to reviewers and anyone scanning the history what this pull request introduces.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-test-init
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-test-init

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ascandone ascandone changed the title Feat/add test init feat: test init Oct 2, 2025
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 37.55274% with 148 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.31%. Comparing base (0bad42a) to head (54bdd17).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/cmd/test_init.go 0.00% 109 Missing ⚠️
internal/specs_format/index.go 70.17% 14 Missing and 3 partials ⚠️
internal/specs_format/runner.go 81.48% 7 Missing and 3 partials ⚠️
internal/utils/utils.go 0.00% 7 Missing ⚠️
internal/cmd/test.go 0.00% 4 Missing ⚠️
internal/cmd/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
- Coverage   71.32%   69.31%   -2.01%     
==========================================
  Files          41       43       +2     
  Lines        4631     4931     +300     
==========================================
+ Hits         3303     3418     +115     
- Misses       1176     1357     +181     
- Partials      152      156       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ascandone ascandone closed this Oct 2, 2025
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.

1 participant