Skip to content

Conversation

@kohsuke
Copy link
Contributor

@kohsuke kohsuke commented May 28, 2025

People who forget to give any tests do not understand that 'subset candidates' are expected, so better to rework the message.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages to clearly distinguish between missing test input and unmatched arguments when no tests are found.
  • Tests
    • Updated test assertions to align with the revised error messaging.

People who forget to give any tests do not understand that 'subset
candidates' are expected, so better to rework the message.
@kohsuke kohsuke requested review from Konboi and Copilot May 28, 2025 20:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

Walkthrough

A new boolean attribute, input_given, was introduced to the Optimize class to track whether test inputs were provided. This attribute is set when adding tests via test_path or scan methods. The run method now uses this flag to display more specific error messages when no tests are found. Corresponding test assertions were updated.

Changes

File(s) Change Summary
launchable/commands/subset.py Added input_given attribute to Optimize; updated methods to set this flag and improved error messaging in run based on its value.
tests/commands/test_subset.py Updated test assertion to use assertIn and refined the checked error message substring.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Optimize

    User->>Optimize: test_path() / scan()
    Optimize->>Optimize: Set input_given = True

    User->>Optimize: run()
    alt No tests found
        alt input_given == True
            Optimize->>User: Error: Arguments did not match any tests
        else input_given == False
            Optimize->>User: Error: No tests provided (with guidance)
        end
    else Tests found
        Optimize->>User: Proceed with subset
    end
Loading

Poem

In the warren of code, a flag now appears,
To track if your tests ever hop in, my dears.
If no tests are found, the message is clear—
Was it empty, or just not here?
With a twitch of the nose, the output is bright,
Guiding lost bunnies to testing done right! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a66ff5a and 1662508.

📒 Files selected for processing (2)
  • launchable/commands/subset.py (4 hunks)
  • tests/commands/test_subset.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: build (windows-latest, 3.6)
  • GitHub Check: build (windows-latest, 3.12)
  • GitHub Check: build (windows-latest, 3.11)
  • GitHub Check: build (windows-latest, 3.10)
  • GitHub Check: build (windows-latest, 3.9)
  • GitHub Check: build (windows-latest, 3.8)
  • GitHub Check: build (windows-latest, 3.7)
  • GitHub Check: build (ubuntu-22.04, 3.12)
  • GitHub Check: build (ubuntu-22.04, 3.11)
  • GitHub Check: build (ubuntu-22.04, 3.10)
  • GitHub Check: build (ubuntu-22.04, 3.9)
  • GitHub Check: build (ubuntu-22.04, 3.8)
  • GitHub Check: build (ubuntu-22.04, 3.7)
🔇 Additional comments (5)
launchable/commands/subset.py (4)

366-366: LGTM: Clear attribute initialization with descriptive comment.

The input_given attribute is properly initialized and the comment clearly explains its purpose.


384-400: LGTM: Proper flag setting in test_path method.

The input_given flag is correctly set to True when the test_path method is called, which accurately tracks when an attempt was made to add test paths. The placement on line 393 ensures the flag is set regardless of whether the path contains wildcards or is processed differently.


446-446: LGTM: Consistent flag setting in scan method.

The input_given flag is properly set in the scan method, maintaining consistency with the test_path method approach.


518-522: Excellent improvement to error messaging clarity.

The conditional error messaging based on the input_given flag significantly improves user experience by distinguishing between two scenarios:

  1. No tests provided at all - guides users to documentation or the --get-tests-from-previous-sessions option
  2. Tests provided but no matches found - indicates the arguments are incorrect/non-existent

This directly addresses the PR objective of making error messages more informative when users forget to supply tests.

tests/commands/test_subset.py (1)

292-292: LGTM: Test assertion properly updated to match new error messaging.

The change from assertTrue to assertIn with the updated substring correctly validates the new conditional error message logic. The test verifies that when no tests are provided (input_given = False), the error message includes guidance about using the --get-tests-from-previous-sessions option.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the error message shown when no subset candidates (tests) are provided. The changes include:

  • Updating the test for asserting the error message.
  • Introducing conditional error messages in the subset command based on whether any test input was provided.
  • Adding a link to the documentation for better guidance.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/commands/test_subset.py Updated test assertion to check for improved error message.
launchable/commands/subset.py Added conditional error message logic and documentation link.
Comments suppressed due to low confidence (2)

tests/commands/test_subset.py:292

  • Ensure that the test consistently triggers the branch expected to output a message containing this substring; if conditions change (e.g., self.input_given being true), the test may need to account for the alternate error message.
self.assertIn("use the `--get-tests-from-previous-sessions` option", result.stdout)

launchable/commands/subset.py:518

  • [nitpick] Consider aligning the error message details between the 'input given' and 'no input' cases so that users receive consistent guidance, even when inputs are provided but unmatched.
if self.input_given:

@sonarqubecloud
Copy link

@kohsuke kohsuke merged commit fc999d5 into main May 29, 2025
16 checks passed
@kohsuke kohsuke deleted the error-msg-improvement branch May 29, 2025 00:02
@github-actions github-actions bot mentioned this pull request May 29, 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.

3 participants