diff --git a/tools/coverage/gcda_clean.py b/tools/coverage/gcda_clean.py index 062b8f356d667670a9344f7e9c809a381aa51112..286f50eae9ab6148fc22074610ea74044ec11b5c 100644 --- a/tools/coverage/gcda_clean.py +++ b/tools/coverage/gcda_clean.py @@ -87,12 +87,15 @@ def clean(pull_id): # convert paddle/fluid/imperative/CMakeFiles/layer.dir/layer.cc.gcda # to paddle/fluid/imperative/layer.cc.gcda - - if trimmed.endswith('.dir'): - trimmed = os.path.dirname(trimmed) - - if trimmed.endswith('CMakeFiles'): - trimmed = os.path.dirname(trimmed) + # modifed to make it more robust + # covert /paddle/build/paddle/phi/backends/CMakeFiles/phi_backends.dir/gpu/cuda/cuda_info.cc.gcda + # to /paddle/build/paddle/phi/backends/gpu/cuda/cuda_info.cc.gcda + trimmed_tmp = [] + for p in trimmed.split('/'): + if p.endswith('.dir') or p.endswith('CMakeFiles'): + continue + trimmed_tmp.append(p) + trimmed = '/'.join(trimmed_tmp) # remove no changed gcda