From: Ian Jackson Date: Fri, 26 Feb 2021 00:43:31 +0000 (+0000) Subject: Make otter --library-add exit NOT_FOUND if added library markers X-Git-Tag: otter-0.4.0~359 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3387c5beeb453316b3c5c1e224fb11c5fc044d63;p=otter.git Make otter --library-add exit NOT_FOUND if added library markers Signed-off-by: Ian Jackson --- diff --git a/apitest.rs b/apitest.rs index b86c7776..076e88f7 100644 --- a/apitest.rs +++ b/apitest.rs @@ -58,6 +58,7 @@ pub use otter::ensure_eq; pub use otter::commands::{MgmtCommand, MgmtResponse}; pub use otter::commands::{MgmtGameInstruction, MgmtGameResponse}; pub use otter::commands::{MgmtGameUpdateMode}; +pub use otter::config::*; pub use otter::{deref_to_field, deref_to_field_mut}; pub use otter::gamestate::{self, Generation, PlayerId}; pub use otter::global::InstanceName; @@ -656,7 +657,7 @@ _ = "error" # rocket #[derive(Copy,Clone,Error,Debug)] #[error("wait status: {0}")] -struct ExitStatusError(pub std::process::ExitStatus); +pub struct ExitStatusError(pub std::process::ExitStatus); impl DirSubst { pub fn specs_dir(&self) -> String { diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 44499163..bb09c6cb 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -132,8 +132,12 @@ impl Ctx { fn library_load(&mut self) { prepare_game(&self.ds, TABLE)?; - self.otter(&self.ds.ss("library-add @table@ wikimedia chess-blue-?")?)?; - // xxx make library-add give distinct exit status here + let add_err = self.otter(&self.ds.ss( + "library-add @table@ wikimedia chess-blue-?" + )?) + .expect_err("library-add succeeded after reset!"); + ensure_eq!(add_err.downcast::()?.0.code(), + Some(EXIT_NOTFOUND)); // xxx find load markers ids let _session = self.connect_player(&self.alice)?; diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 9571c2de..809e98c4 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1223,7 +1223,7 @@ mod library_add { eprintln!("updated game: {}\n\ please adjust markers as desired and run again", msg); - return Ok(()); + exit(EXIT_NOTFOUND); } Good([a, b]) => { // todo: take account of the space used by the markers themselves