-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add crate-level integration tests
Add a sample `Conanfile.txt` and run the `conan install` command using the public crate API. Check that the JSON-formatted Conan output is parsed successfully. Test the Conan command failure handling code in two separate test cases.
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,11 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Install Conan | ||
id: conan | ||
uses: turtlebrowser/[email protected] | ||
- name: Conan version | ||
run: echo "${{ steps.conan.outputs.version }}" | ||
- name: Run tests | ||
run: cargo test --verbose | ||
fmt: | ||
|
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,3 @@ | ||
[requires] | ||
libxml2/2.11.4 | ||
zlib/1.3 |
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,45 @@ | ||
//! conan2-rs integration tests | ||
use std::path::Path; | ||
|
||
use conan2::ConanInstall; | ||
|
||
#[test] | ||
fn run_conan_install() { | ||
let output = ConanInstall::with_recipe(Path::new("tests/conanfile.txt")) | ||
.output_folder(Path::new(env!("CARGO_TARGET_TMPDIR"))) | ||
.build("missing") | ||
.run(); | ||
|
||
assert!(output.is_success()); | ||
assert_eq!(output.status_code(), 0); | ||
|
||
output.parse().emit(); | ||
} | ||
|
||
#[test] | ||
fn fail_no_conanfile() { | ||
let output = ConanInstall::new() | ||
.output_folder(Path::new(env!("CARGO_TARGET_TMPDIR"))) | ||
.run(); | ||
|
||
assert!(!output.is_success()); | ||
assert_eq!(output.status_code(), 1); | ||
assert_eq!(output.stdout().len(), 0); | ||
assert!(output | ||
.stderr() | ||
.starts_with(b"ERROR: Conanfile not found at")); | ||
} | ||
|
||
#[test] | ||
fn fail_no_profile() { | ||
let output = ConanInstall::with_recipe(Path::new("tests/conanfile.txt")) | ||
.output_folder(Path::new(env!("CARGO_TARGET_TMPDIR"))) | ||
.profile("no-such-profile") | ||
.run(); | ||
|
||
assert!(!output.is_success()); | ||
assert_eq!(output.status_code(), 1); | ||
assert_eq!(output.stdout().len(), 0); | ||
assert!(output.stderr().starts_with(b"ERROR: Profile not found: ")); | ||
} |