Finding and deleting unused object map entries

Last edited on

Manually finding and safely removing unused object map entries is not easy. That is why we provide an experimental script called prune_objectmap.py .

This script requires Python 3 on Windows (due to its use of os.path.samefile()), but works with Python 2 or 3 on Unix systems.

Usage

prune_objectmap.py [suitedir] [objectMap-filename]

If only one argument is specified, that is the test suite, or a directory of suites/scripts. If none is specified, the current working directory is used. If a second argument is specified, that is the object map filename. The object map file will be found automatically if the first argument is a valid test suite directory.

This program works on Scripted Object Map files (names.py, names.js, etc), as well as Text Object Maps (objects.map). It searches suitedir for any usage of each object map entry, and removes it from the object map if it is not found anywhere. It retries each search until no more entries can be pruned.

Before writing a modified object map, the original one is renamed to have a .bak extension, so you can always bring back the original if you want.

As it runs, it prints out which entries are pruned from your object map, and when finished, will give you stats about how many were removed/are remaining.