michal/tit

Diff

1e0b97e01e97f78715d52863

scripts/run-linux-armv7

Mode 100755100755; object 368201bfbd2ee7818c2ee5eb

@@ -1,4 +1,17 @@
 #!/bin/sh
 set -eu
 
+case "$0" in
+    /*) test_runner=$0 ;;
+    *) test_runner=$(pwd)/$0 ;;
+esac
+case "$1" in
+    /*) test_executable=$1 ;;
+    *) test_executable=$(pwd)/$1 ;;
+esac
+
+TIT_TEST_RUNNER=$test_runner
+TIT_TEST_EXECUTABLE=$test_executable
+export TIT_TEST_RUNNER TIT_TEST_EXECUTABLE
+
 exec /usr/bin/qemu-arm -L /usr/arm-linux-gnueabihf "$@"

src/lib.rs

Mode 100644100644; object 1ca09a26fb81781fb1785448

@@ -76,6 +76,9 @@
 #[path = "../tests/ssh.rs"]
 mod ssh_tests;
 #[cfg(test)]
+#[path = "../tests/process.rs"]
+mod test_process;
+#[cfg(test)]
 #[path = "../tests/web_session.rs"]
 mod web_session_tests;
 #[cfg(test)]

tests/git_http.rs

Mode 100644100644; object 4952d1d924cccdad45f9dddc

@@ -280,7 +280,7 @@
     let git_binary = command_output(Command::new("which").arg("git"));
     let git_exec_path = command_output(Command::new("git").arg("--exec-path"));
     let driver_path = std::env::var_os("PATH").expect("the test driver PATH");
-    let output = Command::new(std::env::current_exe().expect("find the test executable"))
+    let output = crate::test_process::current_exe()
         .args([
             "--exact",
             "git_http_tests::server_process_does_not_invoke_git",

tests/git_push_ssh.rs

Mode 100644100644; object a7a20a6cfd0802e9b699804b

@@ -454,7 +454,7 @@
     private_key: &Path,
     ready: &Path,
 ) -> Child {
-    Command::new(env::current_exe().expect("find the integration test executable"))
+    crate::test_process::current_exe()
         .args([
             "--exact",
             "git_push_ssh_tests::git_push_crash_child",

tests/process.rs

Mode 100644; object c2b531dd84ee

@@ -1,0 +1,17 @@
+use std::env;
+use std::process::Command;
+
+pub(crate) fn current_exe() -> Command {
+    match (
+        env::var_os("TIT_TEST_RUNNER"),
+        env::var_os("TIT_TEST_EXECUTABLE"),
+    ) {
+        (Some(runner), Some(executable)) => {
+            let mut command = Command::new(runner);
+            command.arg(executable);
+            command
+        }
+        (None, None) => Command::new(env::current_exe().expect("find the current test executable")),
+        _ => panic!("the test runner and test executable must be set together"),
+    }
+}

tests/sqlite.rs

Mode 100644100644; object 6859f8acd703d5920f821032

@@ -1,6 +1,6 @@
 use crate::store;
 
-use std::process::{Child, Command};
+use std::process::Child;
 use std::sync::mpsc;
 use std::sync::{Arc, atomic::AtomicBool, atomic::Ordering};
 use std::thread;
@@ -140,7 +140,7 @@
     database_path: &std::path::Path,
     ready_path: &std::path::Path,
 ) -> Child {
-    Command::new(env::current_exe().expect("find the integration test executable"))
+    crate::test_process::current_exe()
         .args([
             "--exact",
             "sqlite_tests::crash_child",