Skip to content

Commit 80a0fe4

Browse files
chalmerloweparthea
authored andcommitted
chore: improves logic within prerelease_deps session
1 parent d7c0b2b commit 80a0fe4

1 file changed

Lines changed: 29 additions & 32 deletions

File tree

packages/google-cloud-spanner/noxfile.py

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -646,39 +646,36 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
646646
system_test_path = os.path.join("tests", "system.py")
647647
system_test_folder_path = os.path.join("tests", "system")
648648

649-
# Only run system tests for one protobuf implementation on real Spanner to speed up the build.
650-
if os.environ.get("SPANNER_EMULATOR_HOST") or protobuf_implementation == "python":
651-
# Sanity check: Only run system tests if credentials or emulator are set.
652-
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") or os.environ.get("SPANNER_EMULATOR_HOST"):
653-
# Only run system tests if found.
654-
if os.path.exists(system_test_path):
655-
session.run(
656-
"py.test",
657-
"--verbose",
658-
f"--junitxml=system_{session.python}_sponge_log.xml",
659-
system_test_path,
660-
*session.posargs,
661-
env={
662-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
663-
"SPANNER_DATABASE_DIALECT": database_dialect,
664-
"SKIP_BACKUP_TESTS": "true",
665-
},
666-
)
667-
elif os.path.exists(system_test_folder_path):
668-
session.run(
669-
"py.test",
670-
"--verbose",
671-
f"--junitxml=system_{session.python}_sponge_log.xml",
672-
system_test_folder_path,
673-
*session.posargs,
674-
env={
675-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
676-
"SPANNER_DATABASE_DIALECT": database_dialect,
677-
"SKIP_BACKUP_TESTS": "true",
678-
},
679-
)
649+
if os.environ.get("SPANNER_EMULATOR_HOST"):
650+
# Run tests against the emulator
651+
run_system = True
652+
elif protobuf_implementation == "python":
653+
# Run tests against real Spanner, but check creds first
654+
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"):
655+
run_system = True
680656
else:
681-
session.log("Skipping system tests because credentials/emulator are missing")
657+
session.log("Skipping system tests because GOOGLE_APPLICATION_CREDENTIALS is not set")
658+
run_system = False
659+
else:
660+
# Skip to speed up build (only run python implementation on real Spanner)
661+
session.log(f"Skipping system tests for protobuf={protobuf_implementation} on real Spanner to speed up build")
662+
run_system = False
663+
664+
if run_system:
665+
# Run the tests (deduplicated logic)
666+
test_path = system_test_path if os.path.exists(system_test_path) else system_test_folder_path
667+
session.run(
668+
"py.test",
669+
"--verbose",
670+
f"--junitxml=system_{session.python}_sponge_log.xml",
671+
test_path,
672+
*session.posargs,
673+
env={
674+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
675+
"SPANNER_DATABASE_DIALECT": database_dialect,
676+
"SKIP_BACKUP_TESTS": "true",
677+
},
678+
)
682679

683680
@nox.session(python=DEFAULT_PYTHON_VERSION)
684681
def mypy(session):

0 commit comments

Comments
 (0)