-
-
Notifications
You must be signed in to change notification settings - Fork 743
test: use Manifest::read_manifest to insert tsconfig #7832
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
test: use Manifest::read_manifest to insert tsconfig #7832
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge once (if) it's green 🙌
WalkthroughThis change refactors the manifest reading approach in the test utilities. Instead of directly deserialising JSON for package.json and tsconfig.json files, the code now uses a manifest-based reading pattern. An OsFileSystem instance is created to provide filesystem context, and the read_manifest method is delegated to handle parsing for both PackageJson and TsConfigJson types. The public API exports are updated to include Manifest alongside the existing types, whilst error handling logic remains intact through has_errors checks on manifest results. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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
🧹 Nitpick comments (2)
crates/biome_test_utils/src/lib.rs (2)
217-242: LGTM! Consider optional refactor to avoid double-reading.The change correctly uses
read_manifestto ensureinitialize_pathsis called. However, the file is read twice: once at line 218 and again insideread_manifestat line 219.For a minor optimisation, you could call
read_manifestdirectly and only read the file again for diagnostics if errors occur, avoiding double-reading in the success case.Apply this diff for the optional refactor:
- let package_json_file = input_file.with_extension("package.json"); - if let Ok(json) = std::fs::read_to_string(&package_json_file) { - let deserialized = PackageJson::read_manifest(&fs, &package_json_file); + let package_json_file = input_file.with_extension("package.json"); + let deserialized = PackageJson::read_manifest(&fs, &package_json_file); + if deserialized.has_errors() || deserialized.into_deserialized().is_some() { if deserialized.has_errors() { + let json = std::fs::read_to_string(&package_json_file).unwrap_or_default(); diagnostics.extend( deserialized .into_diagnostics() .into_iter() .map(|diagnostic| { diagnostic_to_string( package_json_file.file_stem().unwrap(), &json, diagnostic, ) }), ); } else { project_layout.insert_node_manifest( input_file .parent() .map(|dir_path| dir_path.to_path_buf()) .unwrap_or_default(), deserialized.into_deserialized().unwrap_or_default(), ); } }
244-265: LGTM! Same optional refactor applies here.The tsconfig.json handling correctly uses
read_manifestto ensureinitialize_pathsis called, which was the root cause of the failing CI tests. The same optional refactor to avoid double-reading (suggested for package.json) applies here as well.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/biome_test_utils/src/lib.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_test_utils/src/lib.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_test_utils/src/lib.rs
🧠 Learnings (1)
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference,resolver,flattening}.rs : Avoid recursive type structures and cross-module Arcs; represent links between types using TypeReference and TypeData::Reference.
Applied to files:
crates/biome_test_utils/src/lib.rs
🧬 Code graph analysis (1)
crates/biome_test_utils/src/lib.rs (1)
crates/biome_package/src/node_js_package/tsconfig_json.rs (1)
read_manifest(55-63)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test Node.js API
- GitHub Check: autofix
🔇 Additional comments (2)
crates/biome_test_utils/src/lib.rs (2)
19-19: LGTM!The
Manifesttrait import is necessary for callingread_manifestonPackageJsonandTsConfigJson.
215-215: LGTM!Creating an
OsFileSystemfor the test file's parent directory provides the necessary filesystem context forread_manifest.
|
It's still red, but at least this resolved issues in biome_js_analyze. I'll merge this first and will investigate the next issue |
Probably a test we couldn't catch because of this failure. I can help with that. Feel free to merge this PR anyway |
Summary
Fixed the failing tests on CI.
tsconfig.jsonhas some paths based on where the project exists to resolve path aliases (#7597).TSConfigJson::initialize_pathsneeds to be called before inserting into the project layer. In this pull request, I changed theproject_layout_for_test_filefunction to useTSConfigJson::read_manifest(impl ofManifest::read_manifest) to parse, deserialise and insert the tsconfig.json into the layout.Test Plan
CI should back green.
Docs
N/A