Add more test cases#37
Conversation
Summary of ChangesHello @ehwan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the project's test coverage by adding a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a new example calculator_u8 to serve as a test case for the rusty_lr build script functionality. The changes are logical and correctly set up the new example with a build script to generate the parser from a grammar file. I've identified a few areas for improvement regarding code robustness in the build script and maintainability in the test script. I've also noted that a generated file is missing a final newline, which should be fixed in the generator.
|
|
||
| fn main() { | ||
| println!("cargo::rerun-if-changed=src/parser.rs"); | ||
| let output = format!("{}/parser.rs", std::env::var("OUT_DIR").unwrap()); |
There was a problem hiding this comment.
Using unwrap() can cause the build to panic with a less-than-helpful message if the OUT_DIR environment variable is not set. While Cargo always sets this for build scripts, it's better practice to use expect() with a descriptive message to aid in debugging if something goes wrong.
| let output = format!("{}/parser.rs", std::env::var("OUT_DIR").unwrap()); | |
| let output = format!("{}/parser.rs", std::env::var("OUT_DIR").expect("OUT_DIR environment variable not set")); |
| diff "$rustylr_path/scripts/diff/calculator_u8.rs" "$rustylr_path/scripts/diff/calculator_u8_new.rs" >/dev/null | ||
| if [ $? -ne 0 ]; then | ||
| echo "scripts/diff/ is not updated. Please run scripts/bootstrap_test.sh locally and commit the changes." | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
There's significant duplication in the logic for checking diffs for calculator, calculator_u8, and json. This makes the script harder to maintain. Consider refactoring this repeated logic into a shell function.
For example:
check_diff() {
local name=$1
local base_file="$rustylr_path/scripts/diff/${name}.rs"
local new_file="$rustylr_path/scripts/diff/${name}_new.rs"
diff "$base_file" "$new_file" >/dev/null
if [ $? -ne 0 ]; then
echo "scripts/diff/ is not updated for ${name}. Please run scripts/bootstrap_test.sh locally and commit the changes."
exit 1
fi
}
if [ "$is_from_github_actions" = "true" ]; then
check_diff "calculator"
check_diff "calculator_u8"
check_diff "json"
fi| } | ||
|
|
||
| // ==============================Generated Codes End=============================== | ||
|
No newline at end of file |
There was a problem hiding this comment.
Add
example/calculator_u8to bootstrap test cases