Skip to content

Commit 4a0738d

Browse files
committed
test(conformance): migrate workspace_lifecycle to the conformance suite
Port the workspace and workspace-scoped provider CRUD/isolation/deletion-guard coverage from e2e/rust/tests/workspace_lifecycle.rs into two driver-agnostic scenarios (workspace-lifecycle, workspace-terminating) under tests/suites/conformance/, following the OpenShellRunner/Scenario pattern established for sandbox_lifecycle. Remove the old per-driver test file and its Cargo.toml and tests/artifacts.nix follow-up-exclusion entries. Normalizes miette's line-wrapped diagnostic text before substring-matching error messages; the original test's exact-match assertions were fragile to the terminal width the CLI happened to detect when rendering errors. Verified against an ephemeral Podman gateway. Signed-off-by: politerealism <burdcat17@gmail.com> (cherry picked from commit b3b16f0)
1 parent db94c17 commit 4a0738d

7 files changed

Lines changed: 590 additions & 285 deletions

File tree

‎crates/openshell-conformance/src/lib.rs‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use scenarios::{
2727
FILE_TRANSFER_GIT_FILTERING_SCENARIO, FILE_TRANSFER_PATH_SAFETY_SCENARIO,
2828
FILE_TRANSFER_ROUND_TRIP_SCENARIO, MECHANISTIC_PROPOSAL_SCENARIO,
2929
NEW_HOSTNAME_PROPOSAL_SCENARIO, POLICY_LOCAL_SCENARIO, SANDBOX_LIFECYCLE_SCENARIO,
30-
SMOKE_SCENARIO,
30+
SMOKE_SCENARIO, WORKSPACE_LIFECYCLE_SCENARIO, WORKSPACE_TERMINATING_SCENARIO,
3131
};
3232

3333
/// A portable conformance scenario exercised by the Cargo test suite.
@@ -94,6 +94,28 @@ impl CommandResult {
9494
self.elapsed
9595
}
9696

97+
/// Check combined stdout+stderr for `needle`, normalizing miette's
98+
/// line-wrapped, `│`-continued diagnostic text first so phrase matches
99+
/// don't depend on the terminal width the CLI detected when rendering.
100+
pub fn output_contains(&self, needle: &str) -> bool {
101+
self.normalized_output().contains(needle)
102+
}
103+
104+
/// Case-insensitive variant of [`Self::output_contains`].
105+
pub fn output_contains_ignore_case(&self, needle: &str) -> bool {
106+
self.normalized_output()
107+
.to_lowercase()
108+
.contains(&needle.to_lowercase())
109+
}
110+
111+
fn normalized_output(&self) -> String {
112+
format!("{}{}", self.stdout, self.stderr)
113+
.replace(['\n', '│'], " ")
114+
.split_whitespace()
115+
.collect::<Vec<_>>()
116+
.join(" ")
117+
}
118+
97119
pub fn json<T: DeserializeOwned>(&self) -> Result<T, RunnerError> {
98120
serde_json::from_str(&self.stdout).map_err(|source| RunnerError::InvalidJson {
99121
context: self.context(),
@@ -110,6 +132,20 @@ impl CommandResult {
110132
Err(self.failure_diagnostic(&self.expectation))
111133
}
112134

135+
/// Assert the command's success matches `expect_success` (`false` asserts
136+
/// the command fails, e.g. a rejected duplicate-name or blocked-while-managed case).
137+
pub fn require_outcome(&self, expect_success: bool) -> Result<(), String> {
138+
if self.success() == expect_success {
139+
Ok(())
140+
} else {
141+
Err(self.failure_diagnostic(if expect_success {
142+
"command succeeds"
143+
} else {
144+
"command fails"
145+
}))
146+
}
147+
}
148+
113149
pub fn failure_diagnostic(&self, expectation: &str) -> String {
114150
format!(
115151
"{}\nexpected: {expectation}\nactual: exit {} after {:.1?}\ncommand: {}\nstdout:\n{}\nstderr:\n{}",

‎crates/openshell-conformance/src/scenarios/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod file_transfer;
77
mod policy_behavior;
88
mod sandbox_lifecycle;
99
mod smoke;
10+
mod workspace_lifecycle;
1011

1112
pub use file_transfer::{
1213
FILE_TRANSFER_GIT_FILTERING_SCENARIO, FILE_TRANSFER_PATH_SAFETY_SCENARIO,
@@ -17,3 +18,4 @@ pub use policy_behavior::{
1718
};
1819
pub use sandbox_lifecycle::SANDBOX_LIFECYCLE_SCENARIO;
1920
pub use smoke::SMOKE_SCENARIO;
21+
pub use workspace_lifecycle::{WORKSPACE_LIFECYCLE_SCENARIO, WORKSPACE_TERMINATING_SCENARIO};

0 commit comments

Comments
 (0)