Skip to content

Commit

Permalink
Add some integration test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
JarredAllen committed Jan 7, 2025
1 parent cbfd5b3 commit 93923c9
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Tests
---

This directory contains test cases for this code. Test cases:
* `passing-workspace` is a minimal passing workspace (one crate).
* `failing-workspace` is a minimal failing workspace (one crate).

`test.rs` runs each workspace as a test case and ensures the binary passes or fails as desired.
5 changes: 5 additions & 0 deletions tests/failing-workspace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = ["test-crate"]

[workspace.lints.rustc]
missing-docs = "deny"
6 changes: 6 additions & 0 deletions tests/failing-workspace/test-crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "test-crate"
version = "0.1.0"
edition = "2021"

[dependencies]
Empty file.
5 changes: 5 additions & 0 deletions tests/passing-workspace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = ["test-crate"]

[workspace.lints.rustc]
missing-docs = "deny"
9 changes: 9 additions & 0 deletions tests/passing-workspace/test-crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "test-crate"
version = "0.1.0"
edition = "2021"

[dependencies]

[lints]
workspace = true
Empty file.
23 changes: 23 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::process::Command;

#[test]
fn test_passing_workspace() {
let output = Command::new(env!("CARGO_BIN_EXE_cargo-workspace-lints"))
.arg("workspace-lints")
.arg("tests/passing-workspace/Cargo.toml")
.output()
.expect("Failed to run program");
assert!(output.status.success(), "{output:?}");
}

#[test]
fn test_failing_workspace() {
let output = Command::new(env!("CARGO_BIN_EXE_cargo-workspace-lints"))
.arg("workspace-lints")
.arg("tests/failing-workspace/Cargo.toml")
.output()
.expect("Failed to run program");
assert!(!output.status.success(), "{output:?}");
// Check that it mentions the crate that fails
assert!(String::from_utf8_lossy(&output.stderr).contains("tests/failing-workspace/test-crate"));
}

0 comments on commit 93923c9

Please sign in to comment.