-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,43 @@ | ||
//! Tests for the CLI extension writing. | ||
//! | ||
//! Miri is globally disabled for these tests because they mostly involve | ||
//! calling the CLI binary, which Miri doesn't support. | ||
#![cfg(all(test, not(miri)))] | ||
|
||
use assert_cmd::Command; | ||
use rstest::{fixture, rstest}; | ||
|
||
#[fixture] | ||
fn cmd() -> Command { | ||
let mut cmd = Command::cargo_bin("hugr").unwrap(); | ||
cmd.arg("gen-extensions"); | ||
cmd | ||
} | ||
|
||
#[rstest] | ||
fn test_extension_dump(mut cmd: Command) { | ||
let temp_dir = assert_fs::TempDir::new() | ||
.expect("temp dir creation failure.") | ||
.into_persistent_if(std::env::var_os("HUGR_CLI_TEST_PERSIST_FILES").is_some()); | ||
cmd.arg("-o"); | ||
cmd.arg(temp_dir.path()); | ||
cmd.assert().success(); | ||
|
||
let expected_paths = [ | ||
"logic.json", | ||
"prelude.json", | ||
"ptr.json", | ||
"arithmetic/int/types.json", | ||
"arithmetic/float/types.json", | ||
"arithmetic/int.json", | ||
"arithmetic/float.json", | ||
"arithmetic/conversions.json", | ||
]; | ||
// check all paths exist | ||
for path in expected_paths.iter() { | ||
let full_path = temp_dir.join(path); | ||
assert!(full_path.exists()); | ||
} | ||
|
||
// temp dir deleted when dropped here | ||
} |