Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2618)

Unified Diff: chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py

Issue 2618863002: [Offline Pages] Rename page names saved by test harness to hostnames. (Closed)
Patch Set: Adding full path, removing GUID. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py
diff --git a/chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py b/chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py
index d72635165b0d969dc47bed7cc91100f60cca7333..84d9bb7972562b5aae81832cb0ee19f3ee84c899 100755
--- a/chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py
+++ b/chrome/browser/android/offline_pages/evaluation/run_offline_page_evaluation_test.py
@@ -21,9 +21,11 @@
import argparse
import os
+import re
import shutil
import subprocess
import sys
+import urlparse
DEFAULT_USER_REQUEST = True
DEFAULT_USE_TEST_SCHEDULER = True
@@ -155,9 +157,13 @@ def main(args):
# Also turning off the strict mode so that we won't run into StrictMode
# violations when writing to files.
test_runner_cmd = [
- test_runner_path, '-f',
+ test_runner_path,
+ '-f',
'OfflinePageSavePageLaterEvaluationTest.testFailureRate',
- '--timeout-scale', '20.0', '--strict-mode', 'off',
+ '--timeout-scale',
+ '20.0',
+ '--strict-mode',
+ 'off',
]
if options.verbose:
test_runner_cmd += ['-v']
@@ -184,6 +190,28 @@ def main(args):
]))
print 'Test finished!'
+ print 'Renaming archive files with host names.'
+ pattern = 'Content-Location: (.*)'
+ for filename in os.listdir(archive_dir):
+ path = os.path.join(archive_dir, filename)
+ with open(path) as f:
+ content = f.read()
+ result = re.search(pattern, content)
+ if (result == None):
+ continue
+ url = result.group(1)
+ url_parse = urlparse.urlparse(url)
+ hostname = url_parse[1].replace('.', '_')
+ url_path = re.sub('[^0-9a-zA-Z]+', '_', url_parse[2][1:])
+
+ if (len(hostname) == 0):
+ hostname = 'error_parsing_hostname'
+ continue
+ newname = hostname + '-' + url_path
+ newpath = os.path.join(archive_dir, newname + '.mhtml')
+ os.rename(path, newpath)
+ print 'Renaming finished.'
+
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698