diff options
| author | Camille Mougey <camille.mougey@cea.fr> | 2014-10-31 12:36:05 +0100 |
|---|---|---|
| committer | Camille Mougey <camille.mougey@cea.fr> | 2014-10-31 12:45:35 +0100 |
| commit | 252e52004ee16661b682b30802ccdb69d92c7723 (patch) | |
| tree | 949466b8a7b91948489ea9ad81d9bc7694848a59 /test/utils/testset.py | |
| parent | 8e7d594ecbb94ff06dc0bd34f713950c9129f198 (diff) | |
| download | miasm-252e52004ee16661b682b30802ccdb69d92c7723.tar.gz miasm-252e52004ee16661b682b30802ccdb69d92c7723.zip | |
TestSet: Avoid error on duplicate products cleaning
Diffstat (limited to 'test/utils/testset.py')
| -rw-r--r-- | test/utils/testset.py | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/test/utils/testset.py b/test/utils/testset.py index ca7022fb..5c508836 100644 --- a/test/utils/testset.py +++ b/test/utils/testset.py @@ -158,23 +158,43 @@ class TestSet(object): # Report task finish message_queue.put(MessageTaskDone(test, error)) + @staticmethod + def fast_unify(seq, idfun=None): + """Order preserving unifying list function + @seq: list to unify + @idfun: marker function (default is identity) + """ + if idfun is None: + idfun = lambda x: x + seen = {} + result = [] + for item in seq: + marker = idfun(item) + + if marker in seen: + continue + seen[marker] = 1 + result.append(item) + return result + def clean(self): "Remove produced files" + # Build the list of products + products = [] + current_directory = os.getcwd() for test in self.tests_done: - # Go to the expected directory - current_directory = os.getcwd() - os.chdir(test.base_dir) - - # Remove files for product in test.products: - try: - os.remove(product) - except OSError: - print "Cleanning error: Unable to remove %s" % product - - # Restore directory - os.chdir(current_directory) + # Get the full product path + products.append(os.path.join(current_directory, test.base_dir, + product)) + + # Unify the list and remove products + for product in TestSet.fast_unify(products): + try: + os.remove(product) + except OSError: + print "Cleanning error: Unable to remove %s" % product def add_additionnal_args(self, args): """Add arguments to used on the test command line |