-
Notifications
You must be signed in to change notification settings - Fork 0
Implement graph subcommand with shared Ninja tool invocation and tests #249
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7f07ed5
feat(runner): add `graph` subcommand to invoke ninja graph tool
leynos fbfe855
refactor(runner): unify Ninja tool subcommand handling and improve tests
leynos 9507355
refactor(tests): move feature tests to features_unix and add @unix tag
leynos 9fc4879
test: make cucumber ninja resolution deterministic
leynos d6bfb30
test: split tool subcommand runner tests
leynos 89ce60b
test: share runner fixtures
leynos b7c95f0
test(runner): refactor not found tests to use helper function
leynos bfe336a
test(runner_tool_subcommands): improve ninja exit failure test covera…
leynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //! Shared helpers for integration tests. | ||
| //! | ||
| //! Integration tests under `tests/` compile as independent crates. This module | ||
| //! is included via `mod common;` in individual test files to share fixtures and | ||
| //! helpers while keeping test modules small and avoiding duplication. | ||
|
|
||
| use anyhow::{Context, Result}; | ||
| use rstest::fixture; | ||
| use std::path::PathBuf; | ||
| use test_support::{ | ||
| env::{NinjaEnvGuard, SystemEnv, override_ninja_env}, | ||
| fake_ninja, | ||
| }; | ||
|
|
||
| /// Create a temporary project with a Netsukefile from `minimal.yml`. | ||
| pub fn create_test_manifest() -> Result<(tempfile::TempDir, PathBuf)> { | ||
| let temp = tempfile::tempdir().context("create temp dir for test manifest")?; | ||
| let manifest_path = temp.path().join("Netsukefile"); | ||
| std::fs::copy("tests/data/minimal.yml", &manifest_path) | ||
| .with_context(|| format!("copy minimal.yml to {}", manifest_path.display()))?; | ||
| Ok((temp, manifest_path)) | ||
| } | ||
|
|
||
| /// Fixture: point `NINJA_ENV` at a fake `ninja` with a configurable exit code. | ||
| /// | ||
| /// Returns: (tempdir holding ninja, `NINJA_ENV` guard) | ||
| #[fixture] | ||
| pub fn ninja_with_exit_code( | ||
| #[default(0u8)] exit_code: u8, | ||
| ) -> Result<(tempfile::TempDir, PathBuf, NinjaEnvGuard)> { | ||
| let (ninja_dir, ninja_path) = fake_ninja(exit_code)?; | ||
| let env = SystemEnv::new(); | ||
| let guard = override_ninja_env(&env, ninja_path.as_path()); | ||
| Ok((ninja_dir, ninja_path, guard)) | ||
| } |
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
1 change: 1 addition & 0 deletions
1
tests/features/clean.feature → tests/features_unix/clean.feature
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| @unix | ||
| Feature: Clean subcommand execution | ||
|
|
||
| Scenario: Clean invokes ninja with tool flag | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| @unix | ||
| Feature: Graph subcommand execution | ||
|
|
||
| Scenario: Graph invokes ninja with tool flag | ||
| Given a fake ninja executable that expects the graph tool | ||
| And the CLI is parsed with "graph" | ||
| And the CLI uses the temporary directory | ||
| When the graph process is run | ||
| Then the command should succeed | ||
|
|
||
| Scenario: Graph fails when ninja fails | ||
| Given a fake ninja executable that exits with 1 | ||
| And the CLI is parsed with "graph" | ||
| And the CLI uses the temporary directory | ||
| When the graph process is run | ||
| Then the command should fail with error "ninja exited" | ||
|
|
||
| Scenario: Graph respects jobs flag | ||
| Given a fake ninja executable that expects graph with 4 jobs | ||
| And the CLI is parsed with "-j 4 graph" | ||
| And the CLI uses the temporary directory | ||
| When the graph process is run | ||
| Then the command should succeed | ||
|
|
||
| Scenario: Graph fails when ninja is missing | ||
| Given no ninja executable is available | ||
| And the CLI is parsed with "graph" | ||
| When the graph process is run | ||
| Then the command should fail with error "No such file or directory" | ||
1 change: 1 addition & 0 deletions
1
tests/features/ninja_process.feature → tests/features_unix/ninja_process.feature
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| @unix | ||
| Feature: Ninja process execution | ||
|
|
||
| Scenario: Ninja succeeds | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.