Skip to content
Permalink
Browse files
Enforce deterministic ordering in file walk.
os.walk internally calls os.scandir, whose "entries are yielded in
arbitrary order."  This breaks (at least on my machine) two unit tests
which rely on ordering:

1. test_reprocessing.test_log_collection_tgen
2. test_reprocessing.test_log_collection_torctl

This patch fixes the problem by calling sorted on the arbitrarily
ordered file names.
  • Loading branch information
NullHypothesis committed May 8, 2020
1 parent e5f15ea commit 2ab97fc8082c03ff5f1c8d775f417bfee8936726
Showing with 1 addition and 1 deletion.
  1. +1 −1 onionperf/reprocessing.py
@@ -13,7 +13,7 @@
def collect_logs(dirpath, pattern):
logs = []
for root, dirnames, filenames in os.walk(dirpath):
for filename in fnmatch.filter(filenames, pattern):
for filename in fnmatch.filter(sorted(filenames), pattern):
logs.append(os.path.join(root, filename))
return logs

0 comments on commit 2ab97fc

Please sign in to comment.