moonbitlang / moon

The build system and package manager for MoonBit
https://moonbitlang.github.io/moon/
GNU Affero General Public License v3.0
188 stars 17 forks source link

feat: support doc test #485

Closed Young-Flash closed 6 days ago

peter-jerry-ye-code-review[bot] commented 6 days ago

From the provided git diff output, here are three potential issues or areas of concern based on the changes in the code:

  1. Doc Test Extraction and Patching Logic:

    • The new doc test extraction logic in crates/moon/src/cli/test.rs uses a regex pattern to match doc test blocks. If the regex pattern is not precise, it could lead to incorrect extraction of doc tests, potentially causing false positives or negatives in the tests.
    • The patching logic for doc tests assumes that the doc test blocks are correctly extracted. If there are syntax errors or malformed doc test blocks, the patching process might fail or produce incorrect patch files.
  2. Conflict Between --doc and --update Flags:

    • The handling of the --doc and --update flags in crates/moon/src/cli/test.rs ensures that they cannot be used together (#[clap(long = "doc", conflicts_with = "update")]). However, if a user inadvertently tries to use both flags simultaneously, it could lead to confusion or errors, as the code will reject the command. Providing clear error messages or documentation around this conflict would be beneficial.
  3. Doc Test Patch File Handling in crates/moonbuild/src/entry.rs:

    • The logic for handling doc test patch files checks if the patch file path contains MOON_DOC_TEST_POSTFIX to determine if doc tests should be run. This logic assumes that the patch file path will always be correctly formatted and contain the postfix. If there are discrepancies in the file paths or naming conventions, this could lead to incorrect filtering of test files, potentially causing tests to be skipped unintentionally.

These observations highlight potential areas where careful review and testing would be beneficial to ensure the new doc test functionality works as expected and handles edge cases gracefully.