|
3 | 3 | # |
4 | 4 | # SPDX-License-Identifier: BSD-3-Clause |
5 | 5 |
|
6 | | -import functools |
7 | 6 | import inspect |
8 | 7 | import itertools |
9 | 8 | import json |
@@ -1379,36 +1378,18 @@ def module_unuse(*paths): |
1379 | 1378 | json_report['restored_cases'].append(report.case(*c)) |
1380 | 1379 |
|
1381 | 1380 | report_file = runreport.next_report_filename(report_file) |
| 1381 | + default_loc = os.path.dirname( |
| 1382 | + osext.expandvars(rt.get_default('general/report_file')) |
| 1383 | + ) |
1382 | 1384 | try: |
1383 | | - with open(report_file, 'w') as fp: |
1384 | | - if rt.get_option('general/0/compress_report'): |
1385 | | - jsonext.dump(json_report, fp) |
1386 | | - else: |
1387 | | - jsonext.dump(json_report, fp, indent=2) |
1388 | | - fp.write('\n') |
1389 | | - |
1390 | | - printer.info(f'Run report saved in {report_file!r}') |
| 1385 | + runreport.write_report(json_report, report_file, |
| 1386 | + rt.get_option( |
| 1387 | + 'general/0/compress_report'), |
| 1388 | + os.path.dirname(report_file) == default_loc) |
1391 | 1389 | except OSError as e: |
1392 | 1390 | printer.warning( |
1393 | 1391 | f'failed to generate report in {report_file!r}: {e}' |
1394 | 1392 | ) |
1395 | | - else: |
1396 | | - # Add a symlink to the latest report |
1397 | | - with osext.change_dir(basedir): |
1398 | | - link_name = 'latest.json' |
1399 | | - create_symlink = functools.partial( |
1400 | | - os.symlink, os.path.basename(report_file), link_name |
1401 | | - ) |
1402 | | - if not os.path.exists(link_name): |
1403 | | - create_symlink() |
1404 | | - else: |
1405 | | - if os.path.islink(link_name): |
1406 | | - os.remove(link_name) |
1407 | | - create_symlink() |
1408 | | - else: |
1409 | | - printer.warning('could not create a symlink ' |
1410 | | - 'to the latest report file; ' |
1411 | | - 'path exists and is not a symlink') |
1412 | 1393 |
|
1413 | 1394 | # Generate the junit xml report for this session |
1414 | 1395 | junit_report_file = rt.get_option('general/0/report_junit') |
|
0 commit comments