diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f318a9f..04da54d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,6 +17,8 @@ jobs: - uses: actions/checkout@v3 - name: Build run: cargo build --verbose + - name: Install Conan + run: pip install conan - name: Run tests run: cargo test --verbose fmt: diff --git a/tests/conanfile.txt b/tests/conanfile.txt new file mode 100644 index 0000000..0740b42 --- /dev/null +++ b/tests/conanfile.txt @@ -0,0 +1,3 @@ +[requires] +libxml2/2.11.4 +zlib/1.3 diff --git a/tests/integration_test.rs b/tests/integration_test.rs new file mode 100644 index 0000000..d8ce357 --- /dev/null +++ b/tests/integration_test.rs @@ -0,0 +1,48 @@ +//! 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_eq!( + output.stderr(), + b"ERROR: Profile not found: no-such-profile\n" + ); +}