diff --git a/josh-proxy/src/bin/josh-proxy.rs b/josh-proxy/src/bin/josh-proxy.rs index 7ea23158e..093458d61 100644 --- a/josh-proxy/src/bin/josh-proxy.rs +++ b/josh-proxy/src/bin/josh-proxy.rs @@ -816,6 +816,11 @@ async fn run_proxy() -> josh::JoshResult { ARGS.value_of("local") .ok_or(josh::josh_error("missing local directory"))?, ); + let local = if local.is_absolute() { + local + } else { + std::env::current_dir()?.join(local) + }; josh_proxy::create_repo(&local)?; josh::cache::load(&local)?; diff --git a/tests/proxy/setup_test_env.sh b/tests/proxy/setup_test_env.sh index 778a62007..22c83740d 100644 --- a/tests/proxy/setup_test_env.sh +++ b/tests/proxy/setup_test_env.sh @@ -28,9 +28,9 @@ echo $! > "${TESTTMP}/server_pid" cp -R "${TESTDIR}/../../static/" static if [ -z "${CARGO_TARGET_DIR}" ]; then - TARGET_DIR=${TESTDIR}/../../target + export TARGET_DIR=${TESTDIR}/../../target else - TARGET_DIR=${CARGO_TARGET_DIR} + export TARGET_DIR=${CARGO_TARGET_DIR} fi # shellcheck disable=SC2086 @@ -50,6 +50,7 @@ do if [ $COUNTER -ge 20 ]; then >&2 echo "Starting josh proxy timed out" + cat ${TESTTMP}/josh-proxy.out >&2 exit 1 fi done diff --git a/tests/proxy/shell.t b/tests/proxy/shell.t new file mode 100644 index 000000000..e9d0e6357 --- /dev/null +++ b/tests/proxy/shell.t @@ -0,0 +1,48 @@ + $ . ${TESTDIR}/setup_test_env.sh + $ kill -9 $(cat ${TESTTMP}/proxy_pid) + $ ${TARGET_DIR}/debug/josh-proxy --help + josh-proxy + + USAGE: + josh-proxy [OPTIONS] + + OPTIONS: + -c, --cache-duration + Duration between forced cache refresh + + --gc + Run git gc in maintanance + + -h, --help + Print help information + + --local + + + -n + Number of concurrent upstream git fetch/push operations + + --no-background + + + --poll + + + --port + + + --remote + + + --require-auth + + + --static-resource-proxy-target + Proxy static resource requests to a different URL + + $ ${TARGET_DIR}/debug/josh-proxy --port=8002 --local=../../tmp --remote=http://localhost:8001 2>&1 > proxy.out & + $ sleep 1 + $ kill -9 $! + $ grep "init mirror repo" proxy.out + * DEBUG josh_proxy: init mirror repo: "/tmp/cramtests-*/shell.t/../../tmp/mirror" (glob) + $ rm -Rf ../../tmp