author | Richard Taylor <richard.i.taylor@nokia.com> |
Thu, 03 Dec 2009 14:59:48 +0000 | |
branch | wip |
changeset 32 | fdfc59a2ae7e |
parent 29 | ee00c00df073 |
child 218 | 08ca0919c66d |
permissions | -rw-r--r-- |
3 | 1 |
# |
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
14 |
# Description: |
|
15 |
# |
|
16 |
||
17 |
1# Unit Test for the Raptor_cli (command line interface) module |
|
18 |
||
19 |
import raptor_cli |
|
20 |
import sys |
|
21 |
import unittest |
|
22 |
import os,subprocess |
|
23 |
import re |
|
24 |
||
25 |
class TestRaptorCli(unittest.TestCase): |
|
26 |
||
27 |
def setUp(self): |
|
28 |
sbsHome = os.environ["SBS_HOME"] |
|
29 |
self.windows = sys.platform.lower().startswith("win") |
|
30 |
||
31 |
self.doExportsOnly = False |
|
32 |
self.whatDir = sbsHome + "/test/simple" |
|
33 |
self.listconfig=[] |
|
34 |
self.bldinfvalue=[] |
|
35 |
self.makeoptions=[] |
|
36 |
self.sysdeflayers=[] |
|
37 |
self.sysdeforderlayers = True |
|
38 |
self.whatlist = [] |
|
39 |
self.targets = [] |
|
40 |
self.regexpwin = re.compile(r"^[A-Za-z]:\\",re.I) |
|
41 |
self.RunningQuiet = False |
|
42 |
self.allowCommandLineOverrides = True |
|
43 |
self.ignoreOsDetection = False |
|
44 |
self.filterList = "filter_terminal,filter_logfile" |
|
45 |
||
46 |
def AddConfigName(self,configname): |
|
47 |
self.listconfig.append(configname) |
|
48 |
return True |
|
49 |
||
50 |
def AddConfigList(self,configlist): |
|
51 |
return True |
|
52 |
||
53 |
def AddSpecFile(self,specfilename): |
|
54 |
self.listspec.append(specfilename) |
|
55 |
return True |
|
56 |
||
57 |
def SetRoot(self,root): |
|
58 |
self.rootvalue = root |
|
59 |
return True |
|
60 |
||
61 |
def SetCheck(self,check): |
|
62 |
self.doCheck = check |
|
63 |
return True |
|
64 |
||
65 |
def SetWhat(self,what): |
|
66 |
self.doWhat = what |
|
67 |
return True |
|
68 |
||
69 |
def SetTries(self,tries): |
|
70 |
self.tries = tries |
|
71 |
return True |
|
72 |
||
73 |
def SetSysDefFile(self,sysdef): |
|
74 |
self.sysdefvalue = sysdef |
|
75 |
return True |
|
76 |
||
77 |
def SetSysDefBase(self,sysdefbase): |
|
78 |
self.sysdefbasevalue = sysdefbase |
|
79 |
return True |
|
80 |
||
81 |
def AddSysDefLayer(self,sysdeflayer): |
|
82 |
self.sysdeflayers.append(sysdeflayer) |
|
83 |
return True |
|
84 |
||
85 |
def SetSysDefOrderLayers(self,sysdeforderlayers): |
|
86 |
self.sysdeflayers = sysdeforderlayers |
|
87 |
return True |
|
88 |
||
89 |
def AddBuildInfoFile(self,bldinf): |
|
90 |
self.bldinfvalue.append(bldinf) |
|
91 |
return True |
|
92 |
||
93 |
def RunQuietly(self,QuietMode): |
|
94 |
self.RunningQuiet = QuietMode |
|
95 |
return True |
|
96 |
||
97 |
def SetTopMakefile(self,topmake): |
|
98 |
self.topmake = topmake |
|
99 |
return True |
|
100 |
||
101 |
def SetLogFileName(self, logfile): |
|
102 |
self.logFileName = logfile |
|
103 |
return True |
|
104 |
||
105 |
def SetMakeEngine(self, engine): |
|
106 |
self.makeEngine = engine |
|
107 |
return True |
|
108 |
||
109 |
def AddMakeOption(self, makeOption): |
|
110 |
self.makeOptions.append(makeOption) |
|
111 |
return True |
|
112 |
||
113 |
def SetDebugOutput(self, filename): |
|
114 |
return True |
|
115 |
||
116 |
def SetExportOnly(self, yesOrNo): |
|
117 |
self.doExportOnly = yesOrNo |
|
118 |
return True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
119 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
120 |
def SetNoExport(self, yesOrNo): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
121 |
self.doExport = not yesOrNo |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
122 |
return True |
3 | 123 |
|
124 |
def SetKeepGoing(self, yesOrNo): |
|
125 |
return True |
|
126 |
||
127 |
def SetNoBuild(self, yesOrNo): |
|
128 |
return True |
|
129 |
||
130 |
def SetNoDependInclude(self, yesOrNo): |
|
131 |
return True |
|
132 |
||
133 |
def SetJobs(self, N): |
|
134 |
return True |
|
135 |
||
136 |
def SetToolCheck(self, toolcheck): |
|
137 |
return True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
138 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
139 |
def SetTiming(self, yesOrNo): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
140 |
return True |
3 | 141 |
|
142 |
def SetParallelParsing(self, onoroff): |
|
143 |
self.pp=onoroff |
|
144 |
return True |
|
145 |
||
146 |
def AddProject(self, project): |
|
147 |
return True |
|
148 |
||
149 |
def PrintVersion(self): |
|
150 |
return True |
|
151 |
||
152 |
def Info(self, format, *extras): |
|
153 |
"Send an information message to the configured channel" |
|
154 |
if self.RunningQuiet==False: |
|
155 |
sys.stdout.write(("INFO: " + format + "\n") % extras) |
|
156 |
||
157 |
def Warn(self, format, *extras): |
|
158 |
"Send a warning message to the configured channel" |
|
159 |
sys.stdout.write(("WARNING: " + format + "\n") % extras) |
|
160 |
||
161 |
def IgnoreOsDetection(self, value): |
|
162 |
self.ignoreOsDetection = value |
|
163 |
return True |
|
164 |
||
165 |
def FilterList(self, value): |
|
166 |
self.filterList = value |
|
167 |
return True |
|
168 |
||
169 |
def AddSourceTarget(self, filename): |
|
170 |
self.targets.append(filename) |
|
171 |
||
172 |
def testDoRaptor(self): |
|
173 |
args = ['-c','config1', |
|
174 |
'-c','config name with spaces', |
|
175 |
'-s', 'wrong_file.xml', |
|
176 |
'--sysdef', 'system_definition.xml', |
|
177 |
'-a', 'wrong_base_dir', |
|
178 |
'--sysdefbase', 'C:\definitions', |
|
179 |
'-l', 'a_layer', |
|
180 |
'--layer', 'b_layer', |
|
181 |
'-b', 'bld1.inf', |
|
182 |
'--bldinf', 'bld2.inf', |
|
183 |
'-f', 'a_log_file.log', |
|
184 |
'-m', 'top.mk', |
|
185 |
'--makefile', '/home/Makefile', |
|
186 |
'--filters', 'filter_01,filter_02', |
|
187 |
'--export-only', |
|
188 |
'--source-target', 'some_source_file.cpp', |
|
189 |
'--source-target', 'some_resource_file.rss', |
|
190 |
'--pp', 'on'] |
|
191 |
||
192 |
raptor_cli.GetArgs(self,args) |
|
193 |
self.assertEqual(self.RunningQuiet,False) |
|
194 |
self.assertEqual(self.listconfig[0],'config1') |
|
195 |
self.assertEqual(self.listconfig[1],'config name with spaces') |
|
196 |
self.assertEqual(self.sysdefvalue,'system_definition.xml') |
|
197 |
self.assertEqual(self.sysdefbasevalue,'C:\\definitions') |
|
198 |
self.assertEqual(self.sysdeflayers[0],'a_layer') |
|
199 |
self.assertEqual(self.sysdeflayers[1],'b_layer') |
|
200 |
self.assertEqual(self.bldinfvalue[0],'bld1.inf') |
|
201 |
self.assertEqual(self.bldinfvalue[1],'bld2.inf') |
|
202 |
self.assertEqual(self.topmake,'/home/Makefile') |
|
203 |
self.assertEqual(self.logFileName,'a_log_file.log') |
|
204 |
self.assertEqual(self.filterList,'filter_01,filter_02') |
|
205 |
self.assertEqual(self.doExportOnly,True) |
|
206 |
self.assertEqual(self.targets[0], 'some_source_file.cpp') |
|
207 |
self.assertEqual(self.targets[1], 'some_resource_file.rss') |
|
208 |
self.assertEqual(self.pp, 'on') |
|
209 |
||
210 |
# run all the tests |
|
211 |
||
212 |
from raptor_tests import SmokeTest |
|
213 |
||
214 |
def run(): |
|
215 |
t = SmokeTest() |
|
216 |
t.id = "999" |
|
217 |
t.name = "raptor_cli_unit" |
|
218 |
||
219 |
tests = unittest.makeSuite(TestRaptorCli) |
|
220 |
result = unittest.TextTestRunner(verbosity=2).run(tests) |
|
221 |
||
222 |
if result.wasSuccessful(): |
|
223 |
t.result = SmokeTest.PASS |
|
224 |
else: |
|
225 |
t.result = SmokeTest.FAIL |
|
226 |
||
227 |
return t |