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

Side by Side Diff: chrome/installer/automation_test/test_installer.py

Issue 20578004: Initial commit for the Automated Installer Testing Framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add data. Created 7 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
grt (UTC plus 2) 2013/07/30 03:31:38 the new-style notice is (note: no "(c)" and use th
sukolsak 2013/07/30 15:40:32 Should we put the notice in the data files? The da
gab 2013/07/30 20:44:14 Ya, I don't think we can, but it's pure data, not
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import argparse
6 import json
7 import os
8 import subprocess
9 import verifier
10
11
12 class Config:
13 def __init__(self):
14 self.states = {}
15 self.actions = {}
16 self.tests = []
17
18
19 # Merge the new Property object into the current Property object
grt (UTC plus 2) 2013/07/30 03:31:38 i don't have python readability, so take this with
20 def MergeProperties(current_property, new_property):
21 for key, value in new_property.iteritems():
22 if key not in current_property:
23 current_property[key] = value
24 else:
25 assert(isinstance(current_property[key], dict) and
26 isinstance(value, dict))
27 current_property[key] = dict(
28 current_property[key].items() + value.items())
29
30
31 # Parse a .prop file
32 def ParseProperty(property_filename, dir):
grt (UTC plus 2) 2013/07/30 03:31:38 "dir" is the name of a built-in function. please u
33 property_file = open(os.path.join(dir, property_filename), "r")
grt (UTC plus 2) 2013/07/30 03:31:38 use the "with" statement when opening files here a
34 property = json.load(property_file)
35 property_file.close()
36 return property
37
38
39 # Parse an array of .prop files
40 def ParseProperties(property_filenames, dir):
41 current_property = {}
42 for property_filename in property_filenames:
43 new_property = ParseProperty(property_filename, dir)
44 MergeProperties(current_property, new_property)
45 return current_property
46
47
48 # Parse a .config file
49 def ParseConfig(config_filename):
50 config = Config()
51
52 config_file = open(config_filename, "r")
53 config_data = json.load(config_file)
54 config_file.close()
55 dir = os.path.dirname(os.path.abspath(config_filename))
56
57 for state_name, state_property_filenames in config_data["states"]:
58 config.states[state_name] = ParseProperties(state_property_filenames, dir)
59 for action_name, action_command in config_data["actions"]:
60 config.actions[action_name] = action_command
61 config.tests = config_data["tests"]
62 return config
63
64
65 # Verify that the current machine states match the given machine states
66 def VerifyState(config, state):
67 print " * Current state: " + state
68 verifier.Verify(config.states[state])
69
70
71 def RunCommand(command):
72 print " * Run command: " + command + "\n"
73 subprocess.call(command, shell=True)
74
75
76 def RunResetCommand():
77 print " * Reset\n"
78 # TODO(sukolsak): This might leave artifacts on the machine
79 subprocess.call("mini_installer.exe --chrome --uninstall"
grt (UTC plus 2) 2013/07/30 03:31:38 this isn't a true chrome uninstall command line, a
gab 2013/07/30 13:27:57 As I suggested on a previous patch set, I think we
80 + " & mini_installer.exe --chrome-frame --uninstall", shell=True)
81
82
83 # Test the installer
84 def Test(config):
85 for test in config.tests:
86 print "Testing [ " + " -> ".join(test) + " ]"
87
88 RunResetCommand()
89
90 current_state = test[0]
91 VerifyState(config, current_state)
92
93 for i in range(1, len(test), 2):
94 action = test[i]
95 RunCommand(config.actions[action])
96
97 current_state = test[i + 1]
98 VerifyState(config, current_state)
99
100
101 def main():
102 parser = argparse.ArgumentParser(description="Test the installer.")
103 parser.add_argument("config_filename", help="the config file")
104 args = parser.parse_args()
105
106 config = ParseConfig(args.config_filename)
107 Test(config)
108
109
110 if __name__ == "__main__":
111 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698