Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding script to read the .uses and .classes files from coverage testing
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21515 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
# To test this, use for example: | ||
# rsync -a --progress test.openmodelica.org:/var/www/libraries/ --include=*/ --include="*.uses" --include="*.classes" --exclude='*' --delete . | ||
# python3 CountClassUses.py MSL_3.2.1 ModelicaTest_3.2.1 | ||
# Or use the BuildModelRecursive.mos script to generate the required files | ||
|
||
import glob | ||
from sys import argv | ||
|
||
classes = glob.glob('*/files/*.classes') | ||
|
||
library = argv[1] | ||
for f in argv[1:]: | ||
assert -1 == f.find('/') | ||
|
||
all_classes = dict((c.strip(),[]) for c in open(glob.glob('%s/files/*.classes' % library)[0], 'r').readlines()) | ||
unused_classes = set(all_classes.keys()) # Mainly for debugging since we print out the count of classes... | ||
|
||
for cls in [glob.glob('%s/files/*.uses' % cl) for cl in argv[1:]]: | ||
for cl in cls: | ||
name = cl[:-5].split('files/')[1] | ||
used_classes = set(c.strip() for c in open(cl,'r').readlines()) | ||
unused_classes = unused_classes - used_classes | ||
for c in used_classes: | ||
if c in all_classes: | ||
all_classes[c].append(name) | ||
|
||
for cl in sorted(all_classes, key = lambda cl: (len(all_classes[cl]),cl)): | ||
print(len(all_classes[cl]),cl) |