Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid always re-generating output file in clang coverage driver #37590

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/build/clang_coverage_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import os
import sys

import click
import coloredlogs
Expand Down Expand Up @@ -80,9 +82,16 @@ def main(log_level, no_log_timestamps, output, raw_profile_filename):
log_fmt = "%(levelname)-7s %(message)s"
coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt)

expected_output = jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename)
if os.path.exists(output):
with open(output, 'rt') as f:
if f.read() == expected_output:
logging.info("File %s is already as expected. Will not re-write", output)
sys.exit(0)

logging.info("Writing output to %s (profile name: %s)", output, raw_profile_filename)
with open(output, "wt") as f:
f.write(jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename))
f.write(expected_output)

logging.debug("Writing completed")

Expand Down
Loading