Skip to content

Commit 224fef5

Browse files
committed
Added a --random switch to choose between different test-crawler modes.
- Legacy-Id: 9893
1 parent 2da90c8 commit 224fef5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

bin/test-crawl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ parser.add_argument('--validator-nu', dest='validator_nu', action='store_true',
2828
help='Use validator.nu instead of html5lib for HTML validation')
2929
parser.add_argument('--pedantic', action='store_true',
3030
help='Stop the crawl on the first HTML validation issue')
31+
parser.add_argument('--random', action='store_true',
32+
help='Crawl URLs randomly')
3133
parser.add_argument('--validate-all', dest='validate_all', action='store_true', default=False,
3234
help='Run html 5 validation on all pages, without skipping similar urls. '
3335
'(The default is to only run validation on one of /foo/1/, /foo/2/, /foo/3/, etc.)')
@@ -232,9 +234,12 @@ if __name__ == "__main__":
232234
sys.exit(1)
233235

234236
while urls:
235-
# popitem() is documented to be random, but really isn't
236-
url = random.choice(urls.keys())
237-
referrer = urls.pop(url)
237+
if args.random:
238+
# popitem() is documented to be random, but really isn't
239+
url = random.choice(urls.keys())
240+
referrer = urls.pop(url)
241+
else:
242+
url, referrer = urls.popitem()
238243

239244
visited.add(url)
240245

0 commit comments

Comments
 (0)