Test/integration tests#7
Merged
Merged
Conversation
The core engine (object, refs, tree, commit) previously relied on the OS's global Current Working Directory (CWD) by utilizing hardcoded relative paths (e.g., '.git/objects/'). This implicit coupling to the execution environment rendered the library impure, tightly bound to the terminal state, and inherently thread-unsafe for parallel testing. Transitioned the entire core architecture to explicit Dependency Injection. All filesystem-touching functions now require a `repo_dir: &Path` parameter. `main.rs` has been elevated to a strict 'application boundary' that captures `std::env::current_dir()` exactly once and injects it down the call chain. Architectural Impact: - Eradicated all hidden environmental dependencies and hardcoded '.git/' literals from the library layer. - Transformed the engine from an environment-dependent script into a pure, isolated library capable of manipulating any repository programmatically. - Eliminated global state mutation, establishing a thread-safe foundation that enables parallel, race-condition-free unit testing.
… engine Introduced a robust suite of unit tests across all core library modules (object, refs, tree, commit) utilizing the Arrange-Act-Assert (AAA) pattern. Leveraged the `tempfile` crate to provide isolated, ephemeral filesystems for every test case, ensuring zero side-effects and complete isolation between test runs. Architectural Impact: Because the recent Dependency Injection refactor eradicated implicit reliance on the OS's global Current Working Directory (CWD), these tests no longer require global state mutation (e.g., `env::set_current_dir()`) or serial execution (`--test-threads=1`). The test suite is now inherently thread-safe and executes in parallel, drastically reducing execution time. White-Box Coverage Highlights: - object.rs: Verified pure formatting math, SHA-1 known-value constants, and intentionally fed corrupt Zlib streams to prove the safety nets catch missing null separators and size mismatches. - tree.rs: Mathematically proved the alphabetical sorting algorithm and verified that `.git` directories are correctly ignored during recursive walks. - commit.rs: Validated DAG parent-linking logic and verified the graceful fallback to 'unknown_user' when `.git/config` is missing or malformed. - refs.rs: Tested pointer resolution, branch updates, and the explicit rejection of Detached HEAD states.
Transitioned the project from manual terminal verification to a robust, automated Continuous Integration (CI) pipeline using GitHub Actions. The pipeline triggers on all pushes and pull requests targeting the main branches. Pipeline Guardrails: - Enforces strict code formatting via `cargo fmt --check`. - Mandates zero compiler and Clippy warnings using `-D warnings`, ensuring idiomatic Rust standards are mathematically enforced. - Executes the full suite of parallel-safe unit tests and black-box integration tests via `cargo test --all`. Infrastructure Optimizations: - Integrated `dtolnay/rust-toolchain` for reliable, cross-platform Rust environment provisioning. - Integrated `Swatinem/rust-cache` to cache the `target/` directory between workflow runs, drastically reducing CI execution time from minutes to seconds. Updated README.md with a dynamic CI status badge and expanded CONTRIBUTING.md to document the new local testing requirements for PR approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR transitions
git-rsfrom manual terminal verification to a fully automated, bulletproof testing and continuous integration pipeline.To achieve true test isolation and parallel execution, a massive architectural refactor was performed to eradicate implicit global state (the OS Current Working Directory) from the core library, replacing it with explicit Dependency Injection. Furthermore, a comprehensive suite of white-box unit tests and black-box integration tests has been added, guarded by a new GitHub Actions CI/CD pipeline.
Key Changes:
object,refs,tree,commit,config) no longer relies on hardcoded relative paths (e.g.,.git/). All filesystem-touching functions now require arepo_dir: &Pathparameter.main.rsacts as a strict application boundary, capturingstd::env::current_dir()exactly once and injecting it down the call chain.tempfilecrate. Coverage includes pure math verification, SHA-1 known-value constants, corrupt Zlib stream rejection, tree sorting proofs, and DAG parent-linking logic.assert_cmdthat spawns the compiled binary, executes a full Git workflow (init->hash-object->write-tree->commit), and mathematically verifies the resulting 40-character hex hashes and ref updates..github/workflows/ci.ymlto automatically runcargo fmt,cargo clippy -- -D warnings, andcargo teston all pushes and PRs. IntegratedSwatinem/rust-cachefor fast execution.README.mdand updatedCONTRIBUTING.mdwith local testing requirements.Type of Change
Checklist
cargo fmtcargo clippy --all-targets --all-features -- -D warningsand fixed all warnings