Skip to content

Commit 273fd55

Browse files
authored
chore(librarian): update post processing for google-cloud-spanner (#16802)
Update post processing for noxfile.py following the manual changes in #16764 Validate the changes by generating the client library for `google-cloud-spanner` using these commands: - `export V=v0.10.2-0.20260423145805-fa79d1c1732d` - `go run github.com/googleapis/librarian/tool/cmd/builddockerimages@${V} --version ${V} --language python --revision=fa79d1c1732df4d5d932b64f49fd909d43581ce6` - `docker run -u $(id -u):$(id -g) -v .:/repo -v ~/.cache:/.cache -w /repo docker.io/library/librarian-python:${V} generate -v google-cloud-spanner`
1 parent 094ab6f commit 273fd55

1 file changed

Lines changed: 77 additions & 18 deletions

File tree

.librarian/generator-input/client-post-processing/spanner-integration.yaml

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,12 @@ replacements:
12511251
system_test_path = os.path.join("tests", "system.py")
12521252
system_test_folder_path = os.path.join("tests", "system")
12531253
1254+
system_test_exists = os.path.exists(system_test_path)
1255+
system_test_folder_exists = os.path.exists(system_test_folder_path)
1256+
# Sanity check: only run tests if found.
1257+
if not system_test_exists and not system_test_folder_exists:
1258+
session.skip("System tests were not found")
1259+
12541260
if os.environ.get("SPANNER_EMULATOR_HOST"):
12551261
# Run tests against the emulator
12561262
run_system = True
@@ -1271,24 +1277,77 @@ replacements:
12711277
run_system = False
12721278
12731279
if run_system:
1274-
# Run the tests (deduplicated logic)
1275-
test_path = (
1276-
system_test_path
1277-
if os.path.exists(system_test_path)
1278-
else system_test_folder_path
1279-
)
1280-
session.run(
1281-
"py.test",
1282-
"--verbose",
1283-
f"--junitxml=system_{session.python}_sponge_log.xml",
1284-
test_path,
1285-
*session.posargs,
1286-
env={
1287-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
1288-
"SPANNER_DATABASE_DIALECT": database_dialect,
1289-
"SKIP_BACKUP_TESTS": "true",
1290-
},
1291-
)
1280+
# Run py.test against the system tests.
1281+
if system_test_exists:
1282+
args = [
1283+
"py.test",
1284+
"--quiet",
1285+
"-o",
1286+
"asyncio_mode=auto",
1287+
f"--junitxml=system_{session.python}_sponge_log.xml",
1288+
]
1289+
if not session.posargs:
1290+
args.append(system_test_path)
1291+
args.extend(session.posargs)
1292+
1293+
session.run(
1294+
*args,
1295+
env={
1296+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
1297+
"SPANNER_DATABASE_DIALECT": database_dialect,
1298+
"SKIP_BACKUP_TESTS": "true",
1299+
},
1300+
)
1301+
elif system_test_folder_exists:
1302+
# Run sync tests
1303+
sync_args = [
1304+
"py.test",
1305+
"--quiet",
1306+
"-o",
1307+
"asyncio_mode=auto",
1308+
f"--junitxml=system_{session.python}_sync_sponge_log.xml",
1309+
]
1310+
if not session.posargs:
1311+
sync_args.append(system_test_folder_path)
1312+
sync_args.append(
1313+
f"--ignore={os.path.join(system_test_folder_path, '_async')}"
1314+
)
1315+
else:
1316+
sync_args.extend(session.posargs)
1317+
1318+
session.run(
1319+
*sync_args,
1320+
env={
1321+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
1322+
"SPANNER_DATABASE_DIALECT": database_dialect,
1323+
"SKIP_BACKUP_TESTS": "true",
1324+
},
1325+
)
1326+
1327+
# Run async tests
1328+
async_args = [
1329+
"py.test",
1330+
"--quiet",
1331+
"-o",
1332+
"asyncio_mode=auto",
1333+
f"--junitxml=system_{session.python}_async_sponge_log.xml",
1334+
]
1335+
if not session.posargs:
1336+
async_args.append(os.path.join(system_test_folder_path, "_async"))
1337+
else:
1338+
# If posargs are provided, only run if they match async tests
1339+
# or just skip if they were already run in sync.
1340+
# For simplicity, we only run async folder if no posargs.
1341+
return
1342+
1343+
session.run(
1344+
*async_args,
1345+
env={
1346+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
1347+
"SPANNER_DATABASE_DIALECT": database_dialect,
1348+
"SKIP_BACKUP_TESTS": "true",
1349+
},
1350+
)
12921351

12931352

12941353
@nox.session(python=ALL_PYTHON)

0 commit comments

Comments
 (0)