[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionperf/master] Enforce deterministic ordering in file walk.
commit 2ab97fc8082c03ff5f1c8d775f417bfee8936726
Author: Philipp Winter <phw@xxxxxxxxx>
Date: Fri May 8 10:20:15 2020 -0700
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.
---
onionperf/reprocessing.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/onionperf/reprocessing.py b/onionperf/reprocessing.py
index c5351d4..7acf539 100644
--- a/onionperf/reprocessing.py
+++ b/onionperf/reprocessing.py
@@ -13,7 +13,7 @@ import sys
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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits