chiark / gitweb /
apitest: Make it also a portmanteau
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 16:52:29 +0000 (17:52 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 16:55:39 +0000 (17:55 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
apitest/Cargo.toml
apitest/apitest.rs
apitest/at-otter.rs
apitest/main.rs [new file with mode: 0644]

index f4704c21175e353be43b49d52693ec50019af581..70e96bf51b71d5741180e1888a8c375b8069cd19 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -383,7 +383,7 @@ WDT_DEPS =  $(RUNTEST_DEPS) \
 
 AT_WDT_RUN = $(NAILING_CARGO_JUST_RUN) $(abspath $<)
 
-AT_RUN = $(AT_WDT_RUN) $(basename $(notdir $@))
+AT_RUN = $(AT_WDT_RUN) apitest --test=$(basename $(notdir $@))
 WDT_RUN = $(AT_WDT_RUN) wdriver --test=$(basename $(notdir $@))
 
 for-at:                        $(AT_DEPS)
index 90c7c264db4c5fd1fb9bf978231ec4bb817e10ae..a2572e870e499e4cbdcac68511878231299caa1e 100644 (file)
@@ -20,8 +20,8 @@ name="otter_api_tests"
 path="apitest.rs"
 
 [[bin]]
-name="at-otter"
-path="at-otter.rs"
+name="apitest"
+path="main.rs"
 
 
 [dependencies]
index a9463421691613ae840e6f7f23c297c06e4447b5..04b0b8777933cd4c6382296cbff7a0f006ef8f1a 100644 (file)
@@ -1051,7 +1051,9 @@ pub fn portmanteau_main(prefix: &str){
         s
       } else {
         let s = s.strip_prefix("--test=")
-          .expect("found non-long-option looking for --test={wdt,at}-*");
+          .expect(&format!(
+            "found non-long-option looking for --test={}-*: {:?}",
+            prefix, s));
         if ! plausible(s) {
           panic!("found non --no-bwrap --{}-* option looking for --{}-*",
                  prefix,prefix);
index c3b8bfad4da1b49fca8dd70db451baf9f332e3da..5d7018bbd7b27ac42163b9e0620753447a464a95 100644 (file)
@@ -777,11 +777,11 @@ fn tests(mut c: Ctx) {
 }
 
 #[throws(Explode)]
-fn main() {
+pub fn main() {
   {
     let (opts, _instance, su) = setup_core(
       &[module_path!()],
-      &mut |_|false
+      &mut |s: &OsStr| s.to_str().unwrap().starts_with("--test=")
     )?;
     let spec = su.ds.game_spec_data()?;
     let mut mc = su.mgmt_conn();
diff --git a/apitest/main.rs b/apitest/main.rs
new file mode 100644 (file)
index 0000000..8189752
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use otter_api_tests::*;
+
+portmanteau_has!("at-otter.rs", at_otter);
+
+#[throws(AE)]
+fn main() { portmanteau_main("at")? }