Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👍 Improved test error handling. #16

Merged
merged 1 commit into from
May 12, 2024
Merged

👍 Improved test error handling. #16

merged 1 commit into from
May 12, 2024

Conversation

Milly
Copy link
Contributor

@Milly Milly commented May 10, 2024

Improved test error handling.

  • When Vim/Nvim process startup fails, always wait for a connection timeout. Fixed to finish quickly.
  • If the process terminates abnormally, include the console output in the exception message.
  • Console output (verbose=true) was not supported on Windows. Supported now.
  • Add DENOPS_TEST_CONNECT_TIMEOUT environment variable.
  • Refactoring by using.

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor
    • Enhanced connection handling in withDenops function by restructuring logic for improved error management and operational efficiency.
  • Documentation
    • Updated configuration details indentation in the README for better clarity.

@Milly Milly added the enhancement New feature or request label May 10, 2024
Copy link

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates refine connection handling in withDenops, improving error management. Minor adjustments in configuration indentation for Vim and Neovim unit tests enhance code clarity. These changes boost robustness, particularly in establishing connections and managing operations concurrently.

Changes

File(s) Change Summary
README.md Adjusted Vim and Neovim configuration indentation in unit test setup.
conf.ts Added connectTimeout field to Config interface, handling timeout setting.
runner.ts Introduced RunResult interface for process control and output stream handling.
with.ts Restructured connection logic in withDenops, improved error handling, utilized Promise.race.
with_test.ts Added tests for process abort and connection failure in vim and nvim modes.

🐰✨
Ode to Code, a rabbit's delight,
In the moonlit den, we refine and rewrite.
With hops and leaps through lines so bright,
We craft the magic, in the night's quiet light.
Cheers to changes, small and big,
In our digital burrow, we dance and dig! 🌟
🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between db3e11d and 8fc3cf0.
Files selected for processing (2)
  • README.md (1 hunks)
  • with.ts (3 hunks)
Additional Context Used
LanguageTool (3)
README.md (3)

Near line 14: Using many exclamation marks might seem excessive (in this case: 3 exclamation marks for a text that’s 1403 characters long)
Context: ...://github.com/vim-denops/denops.vim > [!NOTE] > > To use the test function, an...


Near line 23: Loose punctuation mark.
Context: ...tion: > > - DENOPS_TEST_VIM_EXECUTABLE: Path to the Vim executable (default: "v...


Near line 72: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...ll("abs", -4), 4); }, }); ``` If you want to test denops plugins without a real Vim ...

Additional comments not posted (2)
with.ts (2)

92-98: Ensure proper error handling for connection timeouts.

The restructuring of error handling in getConnection to specifically throw a new error for DeadlineError instances is a good practice as it provides clearer error messages to the users.


135-145: Verify the concurrent handling of perform and proc.output().

README.md Show resolved Hide resolved
@Milly Milly marked this pull request as draft May 11, 2024 10:51
@Milly
Copy link
Contributor Author

Milly commented May 11, 2024

Wait #17

@Milly Milly force-pushed the proc branch 2 times, most recently from 2bf4935 to ec641c6 Compare May 12, 2024 14:15
Copy link

codecov bot commented May 12, 2024

Codecov Report

Attention: Patch coverage is 90.67797% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 83.82%. Comparing base (40affa1) to head (84abf02).

Files Patch % Lines
runner.ts 86.04% 6 Missing ⚠️
conf.ts 40.00% 2 Missing and 1 partial ⚠️
with.ts 97.14% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
+ Coverage   82.00%   83.82%   +1.82%     
==========================================
  Files           7        7              
  Lines         389      470      +81     
  Branches       40       50      +10     
==========================================
+ Hits          319      394      +75     
- Misses         70       75       +5     
- Partials        0        1       +1     

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

@Milly Milly changed the title 👍 Do not wait for timeout when Process startup fails 👍 Improved test error handling. May 12, 2024
@Milly Milly marked this pull request as ready for review May 12, 2024 14:29
@Milly Milly requested a review from lambdalisue May 12, 2024 14:31
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Out of diff range and nitpick comments (1)
with.ts (1)

Line range hint 32-183: The refactoring of the withDenops function improves modularity and error handling. Ensure to add test coverage for the error handling during session shutdown.

+ // TODO: Add tests to cover error handling during session shutdown in the withDenops function
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8fc3cf0 and 84abf02.
Files selected for processing (5)
  • README.md (1 hunks)
  • conf.ts (3 hunks)
  • runner.ts (4 hunks)
  • with.ts (4 hunks)
  • with_test.ts (1 hunks)
Additional Context Used
LanguageTool (3)
README.md (3)

Near line 14: Using many exclamation marks might seem excessive (in this case: 3 exclamation marks for a text that’s 1625 characters long)
Context: ...://github.com/vim-denops/denops.vim > [!NOTE] > > To use the test function, an...


Near line 23: Loose punctuation mark.
Context: ...tion: > > - DENOPS_TEST_VIM_EXECUTABLE: Path to the Vim executable (default: "v...


Near line 70: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...ll("abs", -4), 4); }, }); ``` If you want to test denops plugins without a real Vim ...

GitHub Check Runs (1)
codecov/patch success (3)

conf.ts: [warning] 78-78: conf.ts#L78
Added line #L78 was not covered by tests


runner.ts: [warning] 78-82: runner.ts#L78-L82
Added lines #L78 - L82 were not covered by tests


with.ts: [warning] 160-161: with.ts#L160-L161
Added lines #L160 - L161 were not covered by tests

Additional comments not posted (6)
with_test.ts (3)

13-19: The test structure and assertions are correctly implemented for "vim" mode.


21-27: The test structure and assertions are correctly implemented for "nvim" mode.


29-61: The loop correctly generates tests for both process abortion and connection failure scenarios in "vim" and "nvim" modes.

conf.ts (1)

32-37: The addition of the connectTimeout field to the Config interface is well-documented and enhances configuration flexibility.

runner.ts (1)

22-34: The RunResult interface is well-designed, providing encapsulated process management methods and extending AsyncDisposable for better resource management.

README.md (1)

27-28: The documentation updates clearly explain the new DENOPS_TEST_CONNECT_TIMEOUT environment variable and its default value.

conf.ts Show resolved Hide resolved
runner.ts Show resolved Hide resolved
Copy link
Member

@lambdalisue lambdalisue left a comment

Choose a reason for hiding this comment

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

Very nice!

@lambdalisue lambdalisue merged commit 4aa43df into main May 12, 2024
9 checks passed
@lambdalisue lambdalisue deleted the proc branch May 12, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants