diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index ad358c2ea2..2b6f492058 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -765,6 +765,7 @@ def print_infoline(param, value): try: with open(report_file, 'w') as fp: jsonext.dump(json_report, fp, indent=2) + fp.write('\n') except OSError as e: printer.warning( f'failed to generate report in {report_file!r}: {e}' diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 2824b30eb6..ddf1cb31e3 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -164,6 +164,17 @@ def test_report_file_with_sessionid(run_reframe, tmp_path): assert os.path.exists(tmp_path / 'rfm-report-0.json') +def test_report_ends_with_newline(run_reframe, tmp_path): + returncode, stdout, _ = run_reframe( + more_options=[ + f'--report-file={tmp_path / "rfm-report.json"}' + ] + ) + assert returncode == 0 + with open(tmp_path / 'rfm-report.json') as fp: + assert fp.read()[-1] == '\n' + + def test_check_submit_success(run_reframe, remote_exec_ctx): # This test will run on the auto-detected system partition, environ = remote_exec_ctx