Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguishing between unset env. var. and missing file in system test. #2087

Merged
merged 1 commit into from
Aug 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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