Skip to content

Commit e87b1ec

Browse files
ci: create sponge_log.xml files (#722)
* ci: create sponge_log.xml files * test: fix noxfile Co-authored-by: arithmetic1728 <[email protected]>
1 parent 199da47 commit e87b1ec

File tree

3 files changed

+85
-24
lines changed

3 files changed

+85
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ db.sqlite3
2222
# Coverage files
2323
.coverage
2424
coverage.xml
25+
*sponge_log.xml
2526
nosetests.xml
2627
htmlcov/
2728

noxfile.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def unit(session):
8787
session.install(".")
8888
session.run(
8989
"pytest",
90+
f"--junitxml=unit_{session.python}_sponge_log.xml",
9091
"--cov=google.auth",
9192
"--cov=google.oauth2",
9293
"--cov=tests",
@@ -100,7 +101,12 @@ def unit_prev_versions(session):
100101
session.install(".")
101102
session.install(*TEST_DEPENDENCIES)
102103
session.run(
103-
"pytest", "--cov=google.auth", "--cov=google.oauth2", "--cov=tests", "tests"
104+
"pytest",
105+
f"--junitxml=unit_{session.python}_sponge_log.xml",
106+
"--cov=google.auth",
107+
"--cov=google.oauth2",
108+
"--cov=tests",
109+
"tests",
104110
)
105111

106112

@@ -170,6 +176,7 @@ def pypy(session):
170176
session.install(".")
171177
session.run(
172178
"pytest",
179+
f"--junitxml=unit_{session.python}_sponge_log.xml",
173180
"--cov=google.auth",
174181
"--cov=google.oauth2",
175182
"--cov=tests",

system_tests/noxfile.py

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,21 @@ def configure_cloud_sdk(session, application_default_credentials, project=False)
174174
PYTHON_VERSIONS_SYNC = ["2.7", "3.7"]
175175

176176

177+
def default(session, *test_paths):
178+
# replace 'session._runner.friendly_name' with
179+
# session.name once nox has released a new version
180+
# https://github.com/theacodes/nox/pull/386
181+
sponge_log = f"--junitxml=system_{str(session._runner.friendly_name)}_sponge_log.xml"
182+
session.run(
183+
"pytest", sponge_log, *test_paths,
184+
)
185+
186+
177187
@nox.session(python=PYTHON_VERSIONS_SYNC)
178188
def service_account_sync(session):
179189
session.install(*TEST_DEPENDENCIES_SYNC)
180190
session.install(LIBRARY_DIR)
181-
session.run("pytest", "system_tests_sync/test_service_account.py")
191+
default(session, "system_tests_sync/test_service_account.py")
182192

183193

184194
@nox.session(python=PYTHON_VERSIONS_SYNC)
@@ -187,15 +197,21 @@ def default_explicit_service_account(session):
187197
session.env[EXPECT_PROJECT_ENV] = "1"
188198
session.install(*TEST_DEPENDENCIES_SYNC)
189199
session.install(LIBRARY_DIR)
190-
session.run("pytest", "system_tests_sync/test_default.py", "system_tests_sync/test_id_token.py")
200+
default(
201+
session,
202+
"system_tests_sync/test_default.py",
203+
"system_tests_sync/test_id_token.py",
204+
)
191205

192206

193207
@nox.session(python=PYTHON_VERSIONS_SYNC)
194208
def default_explicit_authorized_user(session):
195209
session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
196210
session.install(*TEST_DEPENDENCIES_SYNC)
197211
session.install(LIBRARY_DIR)
198-
session.run("pytest", "system_tests_sync/test_default.py")
212+
default(
213+
session, "system_tests_sync/test_default.py",
214+
)
199215

200216

201217
@nox.session(python=PYTHON_VERSIONS_SYNC)
@@ -205,7 +221,9 @@ def default_explicit_authorized_user_explicit_project(session):
205221
session.env[EXPECT_PROJECT_ENV] = "1"
206222
session.install(*TEST_DEPENDENCIES_SYNC)
207223
session.install(LIBRARY_DIR)
208-
session.run("pytest", "system_tests_sync/test_default.py")
224+
default(
225+
session, "system_tests_sync/test_default.py",
226+
)
209227

210228

211229
@nox.session(python=PYTHON_VERSIONS_SYNC)
@@ -214,15 +232,19 @@ def default_cloud_sdk_service_account(session):
214232
session.env[EXPECT_PROJECT_ENV] = "1"
215233
session.install(*TEST_DEPENDENCIES_SYNC)
216234
session.install(LIBRARY_DIR)
217-
session.run("pytest", "system_tests_sync/test_default.py")
235+
default(
236+
session, "system_tests_sync/test_default.py",
237+
)
218238

219239

220240
@nox.session(python=PYTHON_VERSIONS_SYNC)
221241
def default_cloud_sdk_authorized_user(session):
222242
configure_cloud_sdk(session, AUTHORIZED_USER_FILE)
223243
session.install(*TEST_DEPENDENCIES_SYNC)
224244
session.install(LIBRARY_DIR)
225-
session.run("pytest", "system_tests_sync/test_default.py")
245+
default(
246+
session, "system_tests_sync/test_default.py",
247+
)
226248

227249

228250
@nox.session(python=PYTHON_VERSIONS_SYNC)
@@ -231,7 +253,10 @@ def default_cloud_sdk_authorized_user_configured_project(session):
231253
session.env[EXPECT_PROJECT_ENV] = "1"
232254
session.install(*TEST_DEPENDENCIES_SYNC)
233255
session.install(LIBRARY_DIR)
234-
session.run("pytest", "system_tests_sync/test_default.py")
256+
default(
257+
session, "system_tests_sync/test_default.py",
258+
)
259+
235260

236261
@nox.session(python=PYTHON_VERSIONS_SYNC)
237262
def compute_engine(session):
@@ -240,7 +265,9 @@ def compute_engine(session):
240265
# credentials are detected from environment
241266
del session.virtualenv.env["GOOGLE_APPLICATION_CREDENTIALS"]
242267
session.install(LIBRARY_DIR)
243-
session.run("pytest", "system_tests_sync/test_compute_engine.py")
268+
default(
269+
session, "system_tests_sync/test_compute_engine.py",
270+
)
244271

245272

246273
@nox.session(python=["2.7"])
@@ -282,48 +309,61 @@ def app_engine(session):
282309
# Run the tests
283310
session.env["TEST_APP_URL"] = application_url
284311
session.chdir(HERE)
285-
session.run("pytest", "system_tests_sync/test_app_engine.py")
312+
default(
313+
session, "system_tests_sync/test_app_engine.py",
314+
)
286315

287316

288317
@nox.session(python=PYTHON_VERSIONS_SYNC)
289318
def grpc(session):
290319
session.install(LIBRARY_DIR)
291320
session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.7.0")
292321
session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
293-
session.run("pytest", "system_tests_sync/test_grpc.py")
322+
default(
323+
session, "system_tests_sync/test_grpc.py",
324+
)
294325

295326

296327
@nox.session(python=PYTHON_VERSIONS_SYNC)
297328
def requests(session):
298329
session.install(LIBRARY_DIR)
299330
session.install(*TEST_DEPENDENCIES_SYNC)
300331
session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
301-
session.run("pytest", "system_tests_sync/test_requests.py")
332+
default(
333+
session, "system_tests_sync/test_requests.py",
334+
)
302335

303336

304337
@nox.session(python=PYTHON_VERSIONS_SYNC)
305338
def urllib3(session):
306339
session.install(LIBRARY_DIR)
307340
session.install(*TEST_DEPENDENCIES_SYNC)
308341
session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
309-
session.run("pytest", "system_tests_sync/test_urllib3.py")
342+
default(
343+
session, "system_tests_sync/test_urllib3.py",
344+
)
310345

311346

312347
@nox.session(python=PYTHON_VERSIONS_SYNC)
313348
def mtls_http(session):
314349
session.install(LIBRARY_DIR)
315350
session.install(*TEST_DEPENDENCIES_SYNC, "pyopenssl")
316351
session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
317-
session.run("pytest", "system_tests_sync/test_mtls_http.py")
352+
default(
353+
session, "system_tests_sync/test_mtls_http.py",
354+
)
318355

319356

320-
#ASYNC SYSTEM TESTS
357+
# ASYNC SYSTEM TESTS
358+
321359

322360
@nox.session(python=PYTHON_VERSIONS_ASYNC)
323361
def service_account_async(session):
324-
session.install(*(TEST_DEPENDENCIES_SYNC+TEST_DEPENDENCIES_ASYNC))
362+
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
325363
session.install(LIBRARY_DIR)
326-
session.run("pytest", "system_tests_async/test_service_account.py")
364+
default(
365+
session, "system_tests_async/test_service_account.py",
366+
)
327367

328368

329369
@nox.session(python=PYTHON_VERSIONS_ASYNC)
@@ -332,16 +372,21 @@ def default_explicit_service_account_async(session):
332372
session.env[EXPECT_PROJECT_ENV] = "1"
333373
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
334374
session.install(LIBRARY_DIR)
335-
session.run("pytest", "system_tests_async/test_default.py",
336-
"system_tests_async/test_id_token.py")
375+
default(
376+
session,
377+
"system_tests_async/test_default.py",
378+
"system_tests_async/test_id_token.py",
379+
)
337380

338381

339382
@nox.session(python=PYTHON_VERSIONS_ASYNC)
340383
def default_explicit_authorized_user_async(session):
341384
session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
342385
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
343386
session.install(LIBRARY_DIR)
344-
session.run("pytest", "system_tests_async/test_default.py")
387+
default(
388+
session, "system_tests_async/test_default.py",
389+
)
345390

346391

347392
@nox.session(python=PYTHON_VERSIONS_ASYNC)
@@ -351,7 +396,9 @@ def default_explicit_authorized_user_explicit_project_async(session):
351396
session.env[EXPECT_PROJECT_ENV] = "1"
352397
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
353398
session.install(LIBRARY_DIR)
354-
session.run("pytest", "system_tests_async/test_default.py")
399+
default(
400+
session, "system_tests_async/test_default.py",
401+
)
355402

356403

357404
@nox.session(python=PYTHON_VERSIONS_ASYNC)
@@ -360,15 +407,19 @@ def default_cloud_sdk_service_account_async(session):
360407
session.env[EXPECT_PROJECT_ENV] = "1"
361408
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
362409
session.install(LIBRARY_DIR)
363-
session.run("pytest", "system_tests_async/test_default.py")
410+
default(
411+
session, "system_tests_async/test_default.py",
412+
)
364413

365414

366415
@nox.session(python=PYTHON_VERSIONS_ASYNC)
367416
def default_cloud_sdk_authorized_user_async(session):
368417
configure_cloud_sdk(session, AUTHORIZED_USER_FILE)
369418
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
370419
session.install(LIBRARY_DIR)
371-
session.run("pytest", "system_tests_async/test_default.py")
420+
default(
421+
session, "system_tests_async/test_default.py",
422+
)
372423

373424

374425
@nox.session(python=PYTHON_VERSIONS_ASYNC)
@@ -377,4 +428,6 @@ def default_cloud_sdk_authorized_user_configured_project_async(session):
377428
session.env[EXPECT_PROJECT_ENV] = "1"
378429
session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
379430
session.install(LIBRARY_DIR)
380-
session.run("pytest", "system_tests_async/test_default.py")
431+
default(
432+
session, "system_tests_async/test_default.py",
433+
)

0 commit comments

Comments
 (0)