Skip to content

Commit fea0eca

Browse files
committed
fix(build): Escape newline characters in failure messages for better readability
1 parent be8a1ba commit fea0eca

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

infra/build/functions/build_project.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ def get_compile_step(project,
290290
"""Returns the GCB step for compiling |projects| fuzzers using |env|. The type
291291
of build is specified by |build|."""
292292
failure_msg = (
293-
'*' * 80 + '\nFailed to build.\nTo reproduce, run:\n'
294-
f'python infra/helper.py build_image {project.name}\n'
293+
'*' * 80 + '\\nFailed to build.\\nTo reproduce, run:\\n'
294+
f'python infra/helper.py build_image {project.name}\\n'
295295
'python infra/helper.py build_fuzzers --sanitizer '
296296
f'{build.sanitizer} --engine {build.fuzzing_engine} --architecture '
297-
f'{build.architecture} {project.name}\n' + '*' * 80)
297+
f'{build.architecture} {project.name}\\n' + '*' * 80)
298298
compile_output_redirect = ''
299299

300300
if upload_build_logs:
@@ -442,15 +442,15 @@ def get_build_steps_for_project(project,
442442

443443
if project.run_tests:
444444
failure_msg = (
445-
'*' * 80 + '\nBuild checks failed.\n'
446-
'To reproduce, run:\n'
447-
f'python infra/helper.py build_image {project.name}\n'
445+
'*' * 80 + '\\nBuild checks failed.\\n'
446+
'To reproduce, run:\\n'
447+
f'python infra/helper.py build_image {project.name}\\n'
448448
'python infra/helper.py build_fuzzers --sanitizer '
449449
f'{build.sanitizer} --engine {build.fuzzing_engine} '
450-
f'--architecture {build.architecture} {project.name}\n'
450+
f'--architecture {build.architecture} {project.name}\\n'
451451
'python infra/helper.py check_build --sanitizer '
452452
f'{build.sanitizer} --engine {build.fuzzing_engine} '
453-
f'--architecture {build.architecture} {project.name}\n' +
453+
f'--architecture {build.architecture} {project.name}\\n' +
454454
'*' * 80)
455455
# Test fuzz targets.
456456
test_step = {

infra/build/functions/test_data/expected_trial_build_steps.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"gcr.io/oss-fuzz/skcms",
214214
"bash",
215215
"-c",
216-
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/afl-address-x86_64 && compile || (echo "********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 skcms\n********************************************************************************" && false)"
216+
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/afl-address-x86_64 && compile || (echo \"********************************************************************************\\nFailed to build.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 skcms\\n********************************************************************************\" && false)"
217217
],
218218
"id": "compile-afl-address-x86_64"
219219
},
@@ -251,7 +251,7 @@
251251
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
252252
"bash",
253253
"-c",
254-
"test_all.py || (echo "********************************************************************************\nBuild checks failed.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 skcms\npython infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 skcms\n********************************************************************************" && false)"
254+
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine afl --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer address --engine afl --architecture x86_64 skcms\\n********************************************************************************\" && false)"
255255
],
256256
"id": "build-check-afl-address-x86_64"
257257
},
@@ -305,7 +305,7 @@
305305
"gcr.io/oss-fuzz/skcms",
306306
"bash",
307307
"-c",
308-
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-address-x86_64 && compile || (echo "********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 skcms\n********************************************************************************" && false)"
308+
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-address-x86_64 && compile || (echo \"********************************************************************************\\nFailed to build.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
309309
],
310310
"id": "compile-libfuzzer-address-x86_64"
311311
},
@@ -343,7 +343,7 @@
343343
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
344344
"bash",
345345
"-c",
346-
"test_all.py || (echo "********************************************************************************\nBuild checks failed.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 skcms\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 skcms\n********************************************************************************" && false)"
346+
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
347347
],
348348
"id": "build-check-libfuzzer-address-x86_64"
349349
},
@@ -397,7 +397,7 @@
397397
"gcr.io/oss-fuzz/skcms",
398398
"bash",
399399
"-c",
400-
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-address-i386 && compile || (echo "********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 skcms\n********************************************************************************" && false)"
400+
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-address-i386 && compile || (echo \"********************************************************************************\\nFailed to build.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 skcms\\n********************************************************************************\" && false)"
401401
],
402402
"id": "compile-libfuzzer-address-i386"
403403
},
@@ -435,7 +435,7 @@
435435
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
436436
"bash",
437437
"-c",
438-
"test_all.py || (echo "********************************************************************************\nBuild checks failed.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 skcms\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 skcms\n********************************************************************************" && false)"
438+
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer address --engine libfuzzer --architecture i386 skcms\\npython infra/helper.py check_build --sanitizer address --engine libfuzzer --architecture i386 skcms\\n********************************************************************************\" && false)"
439439
],
440440
"id": "build-check-libfuzzer-address-i386"
441441
},
@@ -489,7 +489,7 @@
489489
"gcr.io/oss-fuzz/skcms",
490490
"bash",
491491
"-c",
492-
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-undefined-x86_64 && compile || (echo "********************************************************************************\nFailed to build.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\n********************************************************************************" && false)"
492+
"rm -r /out && cd /src && cd skcms && mkdir -p /workspace/out/libfuzzer-undefined-x86_64 && compile || (echo \"********************************************************************************\\nFailed to build.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
493493
],
494494
"id": "compile-libfuzzer-undefined-x86_64"
495495
},
@@ -527,7 +527,7 @@
527527
"gcr.io/oss-fuzz-base/base-runner-testing-mybranch",
528528
"bash",
529529
"-c",
530-
"test_all.py || (echo "********************************************************************************\nBuild checks failed.\nTo reproduce, run:\npython infra/helper.py build_image skcms\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\npython infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\n********************************************************************************" && false)"
530+
"test_all.py || (echo \"********************************************************************************\\nBuild checks failed.\\nTo reproduce, run:\\npython infra/helper.py build_image skcms\\npython infra/helper.py build_fuzzers --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\\npython infra/helper.py check_build --sanitizer undefined --engine libfuzzer --architecture x86_64 skcms\\n********************************************************************************\" && false)"
531531
],
532532
"id": "build-check-libfuzzer-undefined-x86_64"
533533
},
@@ -547,4 +547,4 @@
547547
"targets_list > /workspace/targets.list.undefined"
548548
]
549549
}
550-
]
550+
]

0 commit comments

Comments
 (0)