chiark / gitweb /
Make otter --library-add exit NOT_FOUND if added library markers
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Feb 2021 00:43:31 +0000 (00:43 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Feb 2021 00:43:31 +0000 (00:43 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest.rs
apitest/at-otter.rs
src/bin/otter.rs

index b86c77766bfd80b858eb890b67e959734928b8af..076e88f7f129b5bbb346f698d65e06e2821727a9 100644 (file)
@@ -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 {
index 44499163a955ee72ced9d3f247a73bba0866e51d..bb09c6cb2eeac05f37ea43e5aa7c2527dcb9525a 100644 (file)
@@ -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::<ExitStatusError>()?.0.code(),
+               Some(EXIT_NOTFOUND));
     // xxx find load markers ids
 
     let _session = self.connect_player(&self.alice)?;
index 9571c2dedc5c811445979c65c96302062a50eb1e..809e98c431390f400f54bfe0bf02180e38285ea5 100644 (file)
@@ -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