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

Some tests for user-defined meta rules that accept some PEGs as arguments. #14

Merged
merged 6 commits into from
Jun 16, 2024

Conversation

TheVeryDarkness
Copy link
Contributor

@TheVeryDarkness TheVeryDarkness commented Jun 16, 2024

This adds some tests about meta rules. Currently only meta rules that accept PEGs can be defined by users, and users can't define a rule that accepts a slice (like pest::stack::peek).

An example that is tested:

separated(i, sep) = i - (sep - i)*
cell()            = ('a'..'z' | 'A'..'Z' | '0'..'9' | ".")+
main              = separated(separated(cell, " "* - "," - " "*), "\n")

This solves a part of #8.

And this PR includes some updates about CI, as previous PR doesn't actually enable benchmarking correctly.

Summary by CodeRabbit

  • Chores

    • Updated GitHub Actions workflow to run benchmarks on all branches.
    • Renamed and standardized step names in the CI workflow for consistency.
    • Added comments for future improvements and reminders in the CI workflow.
    • Introduced additional configuration options in Codecov for layout, diffs, and profiling.
  • Documentation

    • Enhanced documentation for derive macros, explaining meta rules and rule arguments in struct mapping.
  • Tests

    • Added new tests for custom parsing logic using pest3 to convert input strings into JSON arrays.

Copy link

coderabbitai bot commented Jun 16, 2024

Walkthrough

In this update, several GitHub workflow files and source code are modified to improve continuous integration (CI) and code benchmarking processes, enhance code documentation, and introduce new testing functionality. Benchmarking is now run on all branches, workflow steps are refined for consistency, code coverage visualization is enhanced, explanations in derive macros are expanded, and a custom parser test using pest3 is added.

Changes

Files Change Summary
.github/workflows/benchmark.yml Branch filtering logic altered to run benchmarks on all branches.
.github/workflows/ci.yml Job and step names standardized; comments added for consistency and future improvements; reminders for Codecov token usage.
codedov.yml Added configuration for layout, visualization settings, diffs display, flags, and beta profiling options.
derive/src/lib.rs Enhanced documentation and examples for meta rules, rule arguments, and their application in struct mapping in Rust.
derive/tests/meta_rules.rs Introduced a custom parser using pest3, with parsing rules to convert input strings into JSON arrays, including test functions to validate the logic.

Sequence Diagram(s)

Skipping this section as the changes are varied and do not include a new feature or significant modifications to control flow in a unified manner.

Poem

In the code where changes flow,
Benchmarks run from branch to branch,
CI steps in a seamless dance,
Explanations clear to enhance,
Parsers parse, and tests advance,
Code coverage gets a glance,
A rabbit's joy in every chance.

🐇✨


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b597196 and d9f0c02.

Files selected for processing (5)
  • .github/workflows/benchmark.yml (1 hunks)
  • .github/workflows/ci.yml (2 hunks)
  • codedov.yml (1 hunks)
  • derive/src/lib.rs (1 hunks)
  • derive/tests/meta_rules.rs (1 hunks)
Files skipped from review due to trivial changes (4)
  • .github/workflows/benchmark.yml
  • .github/workflows/ci.yml
  • codedov.yml
  • derive/src/lib.rs
Additional comments not posted (3)
derive/tests/meta_rules.rs (3)

7-13: Define a custom parser with user-defined meta rules.

The parser definition using pest3 and pest3_derive with inline grammar looks correct and effectively utilizes PEGs to define complex parsing rules. This setup follows best practices for defining concise and readable grammars.


15-27: Implement a function to convert input strings into JSON arrays.

The function to_json correctly implements the parsing logic using the pest3 library. The use of iterators and chaining methods enhances the readability and efficiency of the code. Good error handling with Result return type.


29-42: Extensive testing of the custom parser functionality.

The test cases are well-constructed and cover a variety of scenarios, including success cases and expected failures. This thorough testing ensures the robustness of the parser functionality.

@tomtau tomtau merged commit 53d8839 into pest-parser:master Jun 16, 2024
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.

2 participants