Skip to content
Draft
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
13 changes: 8 additions & 5 deletions packages/gapic-generator/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
)

NEWEST_PYTHON = ALL_PYTHON[-2]
SYSTEM_TEST_PYTHON_VERSIONS = ALL_PYTHON


@nox.session(python=ALL_PYTHON)
Expand Down Expand Up @@ -816,12 +817,14 @@ def format(session):
)


@nox.session(python=ALL_PYTHON)
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
def system(session):
# TODO(https://github.com/googleapis/google-cloud-python/issues/16190):
# Implement system test session.
"""Run the system test suite (skipped for migration)."""
session.skip(f"system session is not yet implemented for gapic-generator-python.")
"""Run the system test suite against Showcase."""
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
Comment on lines +824 to +825

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When parsing the RUN_SYSTEM_TESTS environment variable, if a user explicitly sets an invalid value (such as whitespace-only or an invalid boolean string), we should fail fast and raise an error to notify them of the invalid configuration rather than silently falling back to a default value.

    run_env = os.environ.get("RUN_SYSTEM_TESTS", "true")
    if not run_env.strip():
        raise ValueError("RUN_SYSTEM_TESTS cannot be empty or whitespace-only")
    run_system_tests = run_env.strip().lower()
    if run_system_tests not in ["true", "false"]:
        raise ValueError(f"Invalid value for RUN_SYSTEM_TESTS: {run_env}")
    if run_system_tests == "false":
        session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
References
  1. When parsing environment variables, if a user explicitly sets an invalid value (such as whitespace-only), fail fast and raise an error to notify them of the invalid configuration rather than silently falling back to a default value.

session.install("pypandoc_binary")
showcase(session)


@nox.session(python=NEWEST_PYTHON)
Expand Down
Loading