author | Jon Chatten |
Thu, 28 Jan 2010 16:33:36 +0000 | |
branch | fix |
changeset 218 | 08ca0919c66d |
parent 29 | ee00c00df073 |
child 222 | 22e091e03741 |
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 |
||
218
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
17 |
# Unit Test for the Raptor_cli (command line interface) module |
3 | 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" |
|
218
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
45 |
self.noDependInclude = False |
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
46 |
self.noDependGenerate = False |
3 | 47 |
|
48 |
def AddConfigName(self,configname): |
|
49 |
self.listconfig.append(configname) |
|
50 |
return True |
|
51 |
||
52 |
def AddConfigList(self,configlist): |
|
53 |
return True |
|
54 |
||
55 |
def AddSpecFile(self,specfilename): |
|
56 |
self.listspec.append(specfilename) |
|
57 |
return True |
|
58 |
||
59 |
def SetRoot(self,root): |
|
60 |
self.rootvalue = root |
|
61 |
return True |
|
62 |
||
63 |
def SetCheck(self,check): |
|
64 |
self.doCheck = check |
|
65 |
return True |
|
66 |
||
67 |
def SetWhat(self,what): |
|
68 |
self.doWhat = what |
|
69 |
return True |
|
70 |
||
71 |
def SetTries(self,tries): |
|
72 |
self.tries = tries |
|
73 |
return True |
|
74 |
||
75 |
def SetSysDefFile(self,sysdef): |
|
76 |
self.sysdefvalue = sysdef |
|
77 |
return True |
|
78 |
||
79 |
def SetSysDefBase(self,sysdefbase): |
|
80 |
self.sysdefbasevalue = sysdefbase |
|
81 |
return True |
|
82 |
||
83 |
def AddSysDefLayer(self,sysdeflayer): |
|
84 |
self.sysdeflayers.append(sysdeflayer) |
|
85 |
return True |
|
86 |
||
87 |
def SetSysDefOrderLayers(self,sysdeforderlayers): |
|
88 |
self.sysdeflayers = sysdeforderlayers |
|
89 |
return True |
|
90 |
||
91 |
def AddBuildInfoFile(self,bldinf): |
|
92 |
self.bldinfvalue.append(bldinf) |
|
93 |
return True |
|
94 |
||
95 |
def RunQuietly(self,QuietMode): |
|
96 |
self.RunningQuiet = QuietMode |
|
97 |
return True |
|
98 |
||
99 |
def SetTopMakefile(self,topmake): |
|
100 |
self.topmake = topmake |
|
101 |
return True |
|
102 |
||
103 |
def SetLogFileName(self, logfile): |
|
104 |
self.logFileName = logfile |
|
105 |
return True |
|
106 |
||
107 |
def SetMakeEngine(self, engine): |
|
108 |
self.makeEngine = engine |
|
109 |
return True |
|
110 |
||
111 |
def AddMakeOption(self, makeOption): |
|
112 |
self.makeOptions.append(makeOption) |
|
113 |
return True |
|
114 |
||
115 |
def SetDebugOutput(self, filename): |
|
116 |
return True |
|
117 |
||
118 |
def SetExportOnly(self, yesOrNo): |
|
119 |
self.doExportOnly = yesOrNo |
|
120 |
return True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
121 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
122 |
def SetNoExport(self, yesOrNo): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
123 |
self.doExport = not yesOrNo |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
124 |
return True |
3 | 125 |
|
126 |
def SetKeepGoing(self, yesOrNo): |
|
127 |
return True |
|
128 |
||
129 |
def SetNoBuild(self, yesOrNo): |
|
130 |
return True |
|
131 |
||
132 |
def SetNoDependInclude(self, yesOrNo): |
|
133 |
return True |
|
218
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
134 |
|
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
135 |
def SetNoDependGenerate(self, yesOrNo): |
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
136 |
return True |
3 | 137 |
|
138 |
def SetJobs(self, N): |
|
139 |
return True |
|
140 |
||
141 |
def SetToolCheck(self, toolcheck): |
|
142 |
return True |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
143 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
144 |
def SetTiming(self, yesOrNo): |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
145 |
return True |
3 | 146 |
|
147 |
def SetParallelParsing(self, onoroff): |
|
148 |
self.pp=onoroff |
|
149 |
return True |
|
150 |
||
151 |
def AddProject(self, project): |
|
152 |
return True |
|
153 |
||
154 |
def PrintVersion(self): |
|
155 |
return True |
|
156 |
||
157 |
def Info(self, format, *extras): |
|
158 |
"Send an information message to the configured channel" |
|
159 |
if self.RunningQuiet==False: |
|
160 |
sys.stdout.write(("INFO: " + format + "\n") % extras) |
|
161 |
||
162 |
def Warn(self, format, *extras): |
|
163 |
"Send a warning message to the configured channel" |
|
164 |
sys.stdout.write(("WARNING: " + format + "\n") % extras) |
|
165 |
||
166 |
def IgnoreOsDetection(self, value): |
|
167 |
self.ignoreOsDetection = value |
|
168 |
return True |
|
169 |
||
170 |
def FilterList(self, value): |
|
171 |
self.filterList = value |
|
172 |
return True |
|
173 |
||
174 |
def AddSourceTarget(self, filename): |
|
175 |
self.targets.append(filename) |
|
176 |
||
177 |
def testDoRaptor(self): |
|
178 |
args = ['-c','config1', |
|
179 |
'-c','config name with spaces', |
|
180 |
'-s', 'wrong_file.xml', |
|
181 |
'--sysdef', 'system_definition.xml', |
|
182 |
'-a', 'wrong_base_dir', |
|
183 |
'--sysdefbase', 'C:\definitions', |
|
184 |
'-l', 'a_layer', |
|
185 |
'--layer', 'b_layer', |
|
186 |
'-b', 'bld1.inf', |
|
187 |
'--bldinf', 'bld2.inf', |
|
188 |
'-f', 'a_log_file.log', |
|
189 |
'-m', 'top.mk', |
|
190 |
'--makefile', '/home/Makefile', |
|
191 |
'--filters', 'filter_01,filter_02', |
|
192 |
'--export-only', |
|
193 |
'--source-target', 'some_source_file.cpp', |
|
194 |
'--source-target', 'some_resource_file.rss', |
|
218
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
195 |
'--pp', 'on', |
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
196 |
'--no-depend-include', |
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
197 |
'--no-depend-generate'] |
3 | 198 |
|
199 |
raptor_cli.GetArgs(self,args) |
|
200 |
self.assertEqual(self.RunningQuiet,False) |
|
201 |
self.assertEqual(self.listconfig[0],'config1') |
|
202 |
self.assertEqual(self.listconfig[1],'config name with spaces') |
|
203 |
self.assertEqual(self.sysdefvalue,'system_definition.xml') |
|
204 |
self.assertEqual(self.sysdefbasevalue,'C:\\definitions') |
|
205 |
self.assertEqual(self.sysdeflayers[0],'a_layer') |
|
206 |
self.assertEqual(self.sysdeflayers[1],'b_layer') |
|
207 |
self.assertEqual(self.bldinfvalue[0],'bld1.inf') |
|
208 |
self.assertEqual(self.bldinfvalue[1],'bld2.inf') |
|
209 |
self.assertEqual(self.topmake,'/home/Makefile') |
|
210 |
self.assertEqual(self.logFileName,'a_log_file.log') |
|
211 |
self.assertEqual(self.filterList,'filter_01,filter_02') |
|
212 |
self.assertEqual(self.doExportOnly,True) |
|
213 |
self.assertEqual(self.targets[0], 'some_source_file.cpp') |
|
214 |
self.assertEqual(self.targets[1], 'some_resource_file.rss') |
|
215 |
self.assertEqual(self.pp, 'on') |
|
218
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
216 |
self.assertEqual(self.noDependInclude, True) |
08ca0919c66d
First draft tests covering new dependency functionality.
Jon Chatten
parents:
29
diff
changeset
|
217 |
self.assertEqual(self.noDependGenerate, True) |
3 | 218 |
|
219 |
# run all the tests |
|
220 |
||
221 |
from raptor_tests import SmokeTest |
|
222 |
||
223 |
def run(): |
|
224 |
t = SmokeTest() |
|
225 |
t.id = "999" |
|
226 |
t.name = "raptor_cli_unit" |
|
227 |
||
228 |
tests = unittest.makeSuite(TestRaptorCli) |
|
229 |
result = unittest.TextTestRunner(verbosity=2).run(tests) |
|
230 |
||
231 |
if result.wasSuccessful(): |
|
232 |
t.result = SmokeTest.PASS |
|
233 |
else: |
|
234 |
t.result = SmokeTest.FAIL |
|
235 |
||
236 |
return t |