Skip to content

Commit b102cea

Browse files
committed
sync prerelease_deps and system test
1 parent e66d4ad commit b102cea

2 files changed

Lines changed: 77 additions & 18 deletions

File tree

packages/google-cloud-spanner/mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ explicit_package_bases = True
1414
# Performance: reuse results from previous runs to speed up 'nox'
1515
incremental = True
1616

17+

packages/google-cloud-spanner/noxfile.py

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,13 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
655655
system_test_path = os.path.join("tests", "system.py")
656656
system_test_folder_path = os.path.join("tests", "system")
657657

658+
system_test_exists = os.path.exists(system_test_path)
659+
system_test_folder_exists = os.path.exists(system_test_folder_path)
660+
# Sanity check: only run tests if found.
661+
if not system_test_exists and not system_test_folder_exists:
662+
session.skip("System tests were not found")
663+
664+
658665
if os.environ.get("SPANNER_EMULATOR_HOST"):
659666
# Run tests against the emulator
660667
run_system = True
@@ -675,24 +682,75 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
675682
run_system = False
676683

677684
if run_system:
678-
# Run the tests (deduplicated logic)
679-
test_path = (
680-
system_test_path
681-
if os.path.exists(system_test_path)
682-
else system_test_folder_path
683-
)
684-
session.run(
685-
"py.test",
686-
"--verbose",
687-
f"--junitxml=system_{session.python}_sponge_log.xml",
688-
test_path,
689-
*session.posargs,
690-
env={
691-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
692-
"SPANNER_DATABASE_DIALECT": database_dialect,
693-
"SKIP_BACKUP_TESTS": "true",
694-
},
695-
)
685+
# Run py.test against the system tests.
686+
if system_test_exists:
687+
args = [
688+
"py.test",
689+
"--quiet",
690+
"-o",
691+
"asyncio_mode=auto",
692+
f"--junitxml=system_{session.python}_sponge_log.xml",
693+
]
694+
if not session.posargs:
695+
args.append(system_test_path)
696+
args.extend(session.posargs)
697+
698+
session.run(
699+
*args,
700+
env={
701+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
702+
"SPANNER_DATABASE_DIALECT": database_dialect,
703+
"SKIP_BACKUP_TESTS": "true",
704+
},
705+
)
706+
elif system_test_folder_exists:
707+
# Run sync tests
708+
sync_args = [
709+
"py.test",
710+
"--quiet",
711+
"-o",
712+
"asyncio_mode=auto",
713+
f"--junitxml=system_{session.python}_sync_sponge_log.xml",
714+
]
715+
if not session.posargs:
716+
sync_args.append(os.path.join("tests", "system"))
717+
sync_args.append("--ignore=tests/system/_async")
718+
else:
719+
sync_args.extend(session.posargs)
720+
721+
session.run(
722+
*sync_args,
723+
env={
724+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
725+
"SPANNER_DATABASE_DIALECT": database_dialect,
726+
"SKIP_BACKUP_TESTS": "true",
727+
},
728+
)
729+
730+
# Run async tests
731+
async_args = [
732+
"py.test",
733+
"--quiet",
734+
"-o",
735+
"asyncio_mode=auto",
736+
f"--junitxml=system_{session.python}_async_sponge_log.xml",
737+
]
738+
if not session.posargs:
739+
async_args.append(os.path.join("tests", "system", "_async"))
740+
else:
741+
# If posargs are provided, only run if they match async tests
742+
# or just skip if they were already run in sync.
743+
# For simplicity, we only run async folder if no posargs.
744+
return
745+
746+
session.run(
747+
*async_args,
748+
env={
749+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
750+
"SPANNER_DATABASE_DIALECT": database_dialect,
751+
"SKIP_BACKUP_TESTS": "true",
752+
},
753+
)
696754

697755

698756
@nox.session(python=ALL_PYTHON)

0 commit comments

Comments
 (0)