Add TAP test writing guide and GitHub automation improvements#5215
Add TAP test writing guide and GitHub automation improvements#5215renecannao merged 2 commits intov3.0from
Conversation
This file is generated by the Gemini CLI and is not part of the project.
Summary of ChangesHello @renecannao, 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 significantly enhances the development ecosystem by providing clear guidelines for writing robust tests and improving workflow automation. It aims to standardize testing practices and streamline repository management through new GitHub workflows, ultimately contributing to more reliable code and efficient development cycles. 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 introduces a comprehensive guide for writing TAP tests and updates the .gitignore file. The guide is well-written and will be a valuable resource for developers. I've provided one suggestion to improve the code example in the guide to make it more robust and prevent common pitfalls with TAP testing. The pull request description also mentions adding GitHub automation workflows, but the corresponding files do not seem to be included in the diff.
| ok(res && mysql_num_rows(res) == 1, "Rule 999 should exist in stats."); | ||
| if (res && mysql_num_rows(res) == 1) { | ||
| MYSQL_ROW row = mysql_fetch_row(res); | ||
| ok(atoi(row[0]) == 1, "Rule 999 should have exactly 1 hit."); | ||
| } |
There was a problem hiding this comment.
The example test logic has a flaw that could be confusing for new test writers. With a fixed test plan (plan(3)), the number of ok() calls must be constant. Here, one of the ok() calls is inside a conditional block, so if the condition fails, the total number of tests run will not match the plan, causing the test suite to report a 'dubious' result. This can be misleading. Additionally, atoi(row[0]) is unsafe if row or row[0] is NULL, which could lead to a crash. It's better to structure the test to always run the planned number of assertions and to perform NULL checks.
| ok(res && mysql_num_rows(res) == 1, "Rule 999 should exist in stats."); | |
| if (res && mysql_num_rows(res) == 1) { | |
| MYSQL_ROW row = mysql_fetch_row(res); | |
| ok(atoi(row[0]) == 1, "Rule 999 should have exactly 1 hit."); | |
| } | |
| if (res && mysql_num_rows(res) == 1) { | |
| ok(true, "Rule 999 should exist in stats."); | |
| MYSQL_ROW row = mysql_fetch_row(res); | |
| ok(row && row[0] && atoi(row[0]) == 1, "Rule 999 should have exactly 1 hit."); | |
| } else { | |
| ok(false, "Rule 999 should exist in stats."); | |
| ok(false, "Rule 999 hit count is incorrect (rule not found)."); | |
| } |



Summary
Changes
doc/TAP_TESTS_GUIDE.md