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

Side by Side Diff: components/test/data/password_manager/run_tests.py

Issue 386423002: Allow the test bots to easily run the password manager python tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """This file allows the bots to be easily configure and run the tests."""
7
8 import argparse
9 import os
10 import tempfile
11
12 from environment import Environment
13 import tests
14
15 if __name__ == "__main__":
16 parser = argparse.ArgumentParser(
17 description="Password Manager automated tests runner help.")
18 parser.add_argument(
19 "--chrome-path", action="store", dest="chrome_path",
20 help="Set the chrome path (required).", nargs=1, required=True)
21 parser.add_argument(
22 "--chromedriver-path", action="store", dest="chromedriver_path",
23 help="Set the chromedriver path (required).", nargs=1, required=True)
24 parser.add_argument(
25 "--profile-path", action="store", dest="profile_path",
26 help="Set the profile path (required). You just need to choose a "
27 "temporary empty folder. If the folder is not empty all its content "
28 "is going to be removed.",
29 nargs=1, required=True)
30 parser.add_argument(
31 "--passwords-path", action="store", dest="passwords_path",
32 help="Set the usernames/passwords path (required).", nargs=1,
33 required=True)
34 parser.add_argument("--save-path", action="store", nargs=1, dest="save_path",
35 help="Write the results in a file.", required=True)
36 args = parser.parse_args()
37
38 environment = Environment('', '', '', None, False)
39 tests.Tests(environment)
40
41 xml = open(args.save_path[0],"w")
42 results = tempfile.NamedTemporaryFile(dir=os.path.join(tempfile.gettempdir()),
vabr (Chromium) 2014/07/14 12:36:09 nit: Could you break the line so that all the argu
rchtara 2014/07/16 07:55:11 Done.
43 delete=False)
vabr (Chromium) 2014/07/14 12:36:09 Instead of creating the results here, and with del
rchtara 2014/07/16 07:55:11 Done.
44 results_path = results.name
45 results.close()
46
47 full_path = os.path.realpath(__file__)
48 tests_dir = os.path.dirname(full_path)
49 tests_path = os.path.join(tests_dir, "tests.py")
50
51 xml.write("<xml>")
52 for websitetest in environment.websitetests:
53 # repeat the tests three times.
vabr (Chromium) 2014/07/14 12:36:09 Could you please also explain why the tests are re
vabr (Chromium) 2014/07/14 12:36:10 nit: repeat->Repeat (A capital letter at the begin
rchtara 2014/07/16 07:55:11 Done.
54 for x in range(0, 3):
55 os.system("pkill -f chrome")
56 try:
57 os.remove(results_path)
58 except OSError:
59 pass
60
61 os.system("timeout 300 python %s %s --chrome-path %s --chromedriver-path "
vabr (Chromium) 2014/07/14 12:36:09 Please comment on the choice of 300 (including sta
vabr (Chromium) 2014/07/14 12:36:10 @sergiyb: Is this the way tests on trybots should
rchtara 2014/07/16 07:55:11 Done.
Sergiy Byelozyorov 2014/07/16 12:22:43 That doesn't look like a good approach and I hope
rchtara 2014/07/16 16:31:58 OK, I have just posted the question in chrome-reci
62 "%s --passwords-path %s --profile-path %s --save-path %s" %
63 (tests_path, websitetest.name, args.chrome_path[0],
64 args.chromedriver_path[0], args.passwords_path[0],
65 args.profile_path[0], results_path))
66 if os.path.isfile(results_path):
67 results = open(results_path, "r")
68 for line in results:
69 xml.write(line)
70 results.close()
71 else:
72 xml.write("<result><test name='%s' type='prompt' successful='false'>"
73 "</test><test name='%s' type='normal' successful='false'></test>"
74 "</result>" % (websitetest.name, websitetest.name))
75
76 xml.write("</xml>")
77 xml.close()
OLDNEW
« no previous file with comments | « components/test/data/password_manager/environment.py ('k') | components/test/data/password_manager/tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698