Skip to content

Commit d4bff6e

Browse files
committed
chore: improves logic within prerelease_deps session
1 parent 3cda3a8 commit d4bff6e

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

packages/google-cloud-spanner/noxfile.py

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

602-
# Only run system tests for one protobuf implementation on real Spanner to speed up the build.
603-
if os.environ.get("SPANNER_EMULATOR_HOST") or protobuf_implementation == "python":
604-
# Sanity check: Only run system tests if credentials or emulator are set.
605-
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") or os.environ.get("SPANNER_EMULATOR_HOST"):
606-
# Only run system tests if found.
607-
if os.path.exists(system_test_path):
608-
session.run(
609-
"py.test",
610-
"--verbose",
611-
f"--junitxml=system_{session.python}_sponge_log.xml",
612-
system_test_path,
613-
*session.posargs,
614-
env={
615-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
616-
"SPANNER_DATABASE_DIALECT": database_dialect,
617-
"SKIP_BACKUP_TESTS": "true",
618-
},
619-
)
620-
elif os.path.exists(system_test_folder_path):
621-
session.run(
622-
"py.test",
623-
"--verbose",
624-
f"--junitxml=system_{session.python}_sponge_log.xml",
625-
system_test_folder_path,
626-
*session.posargs,
627-
env={
628-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
629-
"SPANNER_DATABASE_DIALECT": database_dialect,
630-
"SKIP_BACKUP_TESTS": "true",
631-
},
632-
)
602+
if os.environ.get("SPANNER_EMULATOR_HOST"):
603+
# Run tests against the emulator
604+
run_system = True
605+
elif protobuf_implementation == "python":
606+
# Run tests against real Spanner, but check creds first
607+
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"):
608+
run_system = True
633609
else:
634-
session.log("Skipping system tests because credentials/emulator are missing")
610+
session.log("Skipping system tests because GOOGLE_APPLICATION_CREDENTIALS is not set")
611+
run_system = False
612+
else:
613+
# Skip to speed up build (only run python implementation on real Spanner)
614+
session.log(f"Skipping system tests for protobuf={protobuf_implementation} on real Spanner to speed up build")
615+
run_system = False
616+
617+
if run_system:
618+
# Run the tests (deduplicated logic)
619+
test_path = system_test_path if os.path.exists(system_test_path) else system_test_folder_path
620+
session.run(
621+
"py.test",
622+
"--verbose",
623+
f"--junitxml=system_{session.python}_sponge_log.xml",
624+
test_path,
625+
*session.posargs,
626+
env={
627+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
628+
"SPANNER_DATABASE_DIALECT": database_dialect,
629+
"SKIP_BACKUP_TESTS": "true",
630+
},
631+
)
635632

636633
@nox.session(python=DEFAULT_PYTHON_VERSION)
637634
def mypy(session):

0 commit comments

Comments
 (0)