From 42658f7605a58ad17cb81d087b2d1457aff6feb1 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Thu, 25 Jan 2018 11:42:30 -0800 Subject: [PATCH] t/t1105-proxy.t: address sensitivity to test env Problem: four subtests of t1105-proxy.t fail when run on a system that is also running a Flux system instance. These tests use the construct FLUX_URI=value VAR=value ... test_must_fail command It looks like the test_must_fail shell function actually does not transmit the environment variable settings to "command", and since FLUX_URI is unset by the test script, the command attempts to connect to the system instance and succeeds. This example, which prints nothing and exits with a code of 1, demonstrates the problem with the construct: #!/bin/sh foo() { "$@" } X=1 foo printenv X Solution: run the command directly and test its exit code, instead of running it with test_must_fail(). --- t/t1105-proxy.t | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/t/t1105-proxy.t b/t/t1105-proxy.t index 93c433835a56..992724c1aa91 100755 --- a/t/t1105-proxy.t +++ b/t/t1105-proxy.t @@ -92,26 +92,26 @@ test_expect_success 'ssh:// can work with events' ' ' test_expect_success 'ssh:// with bad query option fails in flux_open()' ' - FLUX_URI=ssh://localhost/$TEST_JOBID?badarg=bar FLUX_SSH=$TEST_SSH \ - test_must_fail flux getattr size 2>badarg.out && + ! FLUX_URI=ssh://localhost/$TEST_JOBID?badarg=bar FLUX_SSH=$TEST_SSH \ + flux getattr size 2>badarg.out && grep -q "flux_open:" badarg.out ' test_expect_success 'ssh:// with bad FLUX_SSH value fails in flux_open()' ' - FLUX_URI=ssh://localhost/$TEST_JOBID FLUX_SSH=/noexist \ - test_must_fail flux getattr size 2>noexist.out && + ! FLUX_URI=ssh://localhost/$TEST_JOBID FLUX_SSH=/noexist \ + flux getattr size 2>noexist.out && grep -q "flux_open:" noexist.out ' test_expect_success 'ssh:// with bad FLUX_SSH_RCMD value fails in flux_open()' ' - FLUX_URI=ssh://localhost/$TEST_JOBID FLUX_SSH=$TEST_SSH \ - FLUX_SSH_RCMD=/nocmd test_must_fail flux getattr size 2>nocmd.out && + ! FLUX_URI=ssh://localhost/$TEST_JOBID FLUX_SSH=$TEST_SSH \ + FLUX_SSH_RCMD=/nocmd flux getattr size 2>nocmd.out && grep -q "flux_open:" nocmd.out ' test_expect_success 'ssh:// with missing path component fails in flux_open()' ' - FLUX_URI=ssh://localhost FLUX_SSH=$TEST_SSH \ - test_must_fail flux getattr size 2>nopath.out && + ! FLUX_URI=ssh://localhost FLUX_SSH=$TEST_SSH \ + flux getattr size 2>nopath.out && grep -q "flux_open:" nopath.out '