Skip to content

Cover example runner timeout parsing#910

Open
Baagheera wants to merge 4 commits into
fedify-dev:mainfrom
Baagheera:example-timeout-test
Open

Cover example runner timeout parsing#910
Baagheera wants to merge 4 commits into
fedify-dev:mainfrom
Baagheera:example-timeout-test

Conversation

@Baagheera

Copy link
Copy Markdown

Summary

  • extract the example test runner's CLI parsing into a small helper so it can be tested without starting examples
  • cover the documented default timeout and --timeout VALUE handling
  • keep the runner importable by guarding execution with import.meta.main

Fixes #887.

Testing

  • deno fmt --check deno.json examples/test-examples/mod.ts examples/test-examples/mod.test.ts
  • deno lint examples/test-examples/mod.ts examples/test-examples/mod.test.ts
  • deno test --check --doc --allow-all --unstable-kv --trace-leaks --parallel examples/test-examples/mod.test.ts
  • deno run -A examples/test-examples/mod.ts --timeout=123 cloudflare-workers

AI assistance

Prepared with assistance from Codex:gpt-5. I reviewed the issue, project instructions, diff, and local test output before opening this PR.

@netlify

netlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit debb922
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a43b5d96b659900083196b1

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 41931615-192a-473e-903a-876d7d0d2fd6

📥 Commits

Reviewing files that changed from the base of the PR and between 7a5e2ec and 1be5170.

📒 Files selected for processing (2)
  • examples/test-examples/mod.test.ts
  • examples/test-examples/mod.ts

📝 Walkthrough

Walkthrough

Refactors examples/test-examples/mod.ts to extract CLI parsing into parseCliArgs with a CliOptions type and move logging into configureLogging. Adds --timeout test coverage, includes the example tests in deno.json, and records the change in CHANGES.md.

Changes

Example test runner CLI refactor and tests

Layer / File(s) Summary
CLI parsing and runner startup
examples/test-examples/mod.ts
Adds CliOptions and parseCliArgs(args) for --timeout, --debug/-d, and positional filters, replaces module-level logging setup with configureLogging(debugMode), changes MultiHandleExample.cmdPrefix to required cmd, updates main to use parsed args and logging, and guards auto-run with import.meta.main.
CLI parsing tests
examples/test-examples/mod.test.ts
Adds focused parseCliArgs tests for default values, --timeout forms, debug flags, invalid timeout inputs, and timeout arguments that should not become filter names.
Test inclusion and changelog
deno.json, CHANGES.md
Adds the example test runner path to deno.json test inclusion and records the timeout coverage change in CHANGES.md.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main change: example runner timeout parsing.
Description check ✅ Passed The description matches the changeset and explains the timeout parsing and importability updates.
Linked Issues check ✅ Passed The PR implements and tests the example runner's --timeout handling, satisfying #887's requirement.
Out of Scope Changes check ✅ Passed The changelog, test inclusion, and runner changes all support the timeout parsing work and are in scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

The example test runner documents --timeout, but the option did not have focused coverage. This extracts argument parsing into a pure helper so the documented forms can be checked without starting examples.

While making the module importable, this also aligns the multi-handle example type with the cmd field the runner already uses.

Issue: fedify-dev#887

Assisted-by: Codex:gpt-5
@Baagheera Baagheera force-pushed the example-timeout-test branch from 0a23695 to a21d370 Compare June 30, 2026 12:06

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the example test runner by extracting CLI argument parsing into a dedicated parseCliArgs function and adding comprehensive unit tests. It also modularizes the logging configuration and ensures the main execution block only runs when the module is executed directly. Feedback is provided regarding potential NaN propagation when parsing non-numeric values for the --timeout option, which could cause server readiness checks to fail immediately.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/test-examples/mod.ts Outdated
@Baagheera Baagheera marked this pull request as ready for review June 30, 2026 12:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/test-examples/mod.ts`:
- Around line 138-141: Validate the timeout value before assigning it in
parseCliArgs: in the `--timeout` and `--timeout=` branches, only consume the
next argument or slice value if it is present and parses to a finite number. If
the value is missing or invalid, leave `defaultTimeoutMs` unchanged and continue
parsing so flags like `--debug` are not skipped; update the `parseCliArgs` logic
around the `arg === "--timeout"` and `arg.startsWith("--timeout=")` checks
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3cb86a7a-83ed-45d7-9c79-522ef626e878

📥 Commits

Reviewing files that changed from the base of the PR and between 5b68574 and a21d370.

📒 Files selected for processing (4)
  • CHANGES.md
  • deno.json
  • examples/test-examples/mod.test.ts
  • examples/test-examples/mod.ts

Comment thread examples/test-examples/mod.ts Outdated
Invalid --timeout values could previously become NaN and skip a following flag. Keep the default unless the option receives a positive finite value, and cover the review case.

Addresses review feedback on fedify-dev#910.

Assisted-by: Codex:gpt-5

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/test-examples/mod.ts`:
- Around line 145-149: The parseCliArgs handling for "--timeout" is leaving
invalid non-flag values like "abc" in the argument stream, which later makes
them get treated as filterNames. Update the "--timeout" branch in parseCliArgs
so the next token is consumed whenever it is present and not another flag, even
if parseTimeoutMs returns null, while still leaving the token untouched only
when it is missing or already starts with "--". Keep the existing
defaultTimeoutMs and i advancement logic aligned with this behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f59e8cfc-bb45-440d-ae8e-c89ea14f4f2a

📥 Commits

Reviewing files that changed from the base of the PR and between a21d370 and 7a5e2ec.

📒 Files selected for processing (2)
  • examples/test-examples/mod.test.ts
  • examples/test-examples/mod.ts

Comment thread examples/test-examples/mod.ts Outdated
Invalid non-flag values after --timeout should not become example filters. Consume those values while leaving real flags available for normal parsing.

Addresses follow-up review feedback on fedify-dev#910.

Assisted-by: Codex:gpt-5
Comment thread CHANGES.md Outdated
The example runner test coverage does not change user-facing API, so leave CHANGES.md untouched.

Addresses maintainer feedback on fedify-dev#910.

Assisted-by: Codex:gpt-5
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.

Make the example test runner honor --timeout

2 participants