chiark / gitweb /
jstest: Provide for wrapping
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 8 Jul 2021 19:40:16 +0000 (20:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 8 Jul 2021 19:40:16 +0000 (20:40 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
jstest/jst-lower.rs
jstest/jstest.rs
jstest/lower.nodejs
jstest/run1

index fe60acc10fb6682416df0884f3f7684c447ce170..0a688acf62493ed50a3496c1c49dd992749b18a1 100644 (file)
@@ -4,6 +4,17 @@
 
 use otter_nodejs_tests::*;
 
+#[derive(StructOpt)]
+struct Opts {
+  pub nodejs: String,
+  pub script: String,
+}
+
 #[throws(AE)]
 fn main() {
+  let opts = Opts::from_args();
+  let mut cmd = Command::new(opts.nodejs);
+  cmd.arg(opts.script);
+  let status = cmd.status()?;
+  assert!(status.success(), "{}", status);
 }
index 52b070ed88c1f3d3678c6811a0e432972a01940e..d1493843230ecfb54d9468ec0f24fb8883615db3 100644 (file)
@@ -3,3 +3,5 @@
 // There is NO WARRANTY.
 
 pub use otter::prelude::*;
+
+pub use structopt::StructOpt;
index 55ef29a3c06a00f77f2cb1300b321140d4afe834..f941330a000fba947b047249b4b418e9d204714e 100644 (file)
@@ -4,6 +4,8 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
+// @@wrap jst-lower
+
 const fs = require('fs');
 let wasm_bindgen = require('otter_wasm.js');
 
index 3676e9678c07b8e368cfb26f0c99f192ee6335b6..c30fb92b81d1b51f2bffc64997121039896aa477 100755 (executable)
@@ -29,6 +29,13 @@ if grep '^\/\/ @expect' $1; then
 else
        rm -f expect
 fi
+wrap=$(sed -n 's/^\/\/ @@wrap //p' $1)
+
+case "$wrap" in
+'')    ;;
+*/*)   fail "uh $wrap" ;;
+*)     wrap=../../target/debug/$wrap
+esac
 
 exec 3>run.js
 sed >&3 <script.js '/^\/\/@@notest/,/^\/\/@@/d'
@@ -36,7 +43,7 @@ cat >&3 $t.nodejs
 exec 3>&-
 
 set +e
-nodejs run.js >output
+$wrap nodejs run.js >output
 rc=$?
 set -e