Skip to content

Commit

Permalink
Distinguishing between unset env. var. and missing file in system test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Aug 11, 2016
1 parent 27f0af5 commit a824bdc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions system_tests/system_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
ENVIRON_ERROR_MSG = """\
To run the system tests, you need to set some environment variables.
Please check the CONTRIBUTING guide for instructions.
Missing variables: %s
"""


Expand All @@ -47,15 +45,24 @@ def create_scoped_required():

def check_environ():
missing = []
extra = ''

if PROJECT_ID is None:
missing.append(TESTS_PROJECT)

if CREDENTIALS is None or not os.path.isfile(CREDENTIALS):
if CREDENTIALS is None:
missing.append(TEST_CREDENTIALS)

if missing:
print(ENVIRON_ERROR_MSG % ', '.join(missing), file=sys.stderr)
elif not os.path.isfile(CREDENTIALS):
extra = '\nThe %s path %r is not a file.' % (TEST_CREDENTIALS,
CREDENTIALS)

if missing or extra:
msg = ENVIRON_ERROR_MSG
if missing:
msg += '\nMissing variables: ' + ', '.join(missing)
if extra:
msg += extra
print(msg, file=sys.stderr)
sys.exit(1)


Expand Down

0 comments on commit a824bdc

Please sign in to comment.