Skip to content

Commit

Permalink
t/t1105-proxy.t: address sensitivity to test env
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
garlick committed Jan 30, 2018
1 parent f0eb9b0 commit 42658f7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions t/t1105-proxy.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
'

Expand Down

0 comments on commit 42658f7

Please sign in to comment.