sbsv2/raptor/test/unit_suite/raptor_api_unit.py
changeset 28 b8fa7dfeeaa1
parent 18 de5b887c98f7
--- a/sbsv2/raptor/test/unit_suite/raptor_api_unit.py	Wed Aug 04 12:07:55 2010 +0100
+++ b/sbsv2/raptor/test/unit_suite/raptor_api_unit.py	Wed Oct 06 15:13:17 2010 +0100
@@ -18,6 +18,7 @@
 import raptor
 import raptor_api
 import unittest
+import raptor_tests
 
 class TestRaptorApi(unittest.TestCase):
 			
@@ -30,7 +31,7 @@
 		
 	def testAliases(self):
 		r = raptor.Raptor()
-		r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") )
+		r.cache.Load( generic_path.Join(r.home, "test", "configapi", "api.xml") )
 
 		api = raptor_api.Context(r)
 	
@@ -39,6 +40,9 @@
 		self.failUnlessEqual(set(["alias_A","alias_B","s1","s2"]),
 							 set(a.name for a in aliases))
 		
+		aliaslist = [a.name for a in aliases] # verify that the list is sorted
+		self.failUnlessEqual(["alias_A","alias_B","s1","s2"], aliaslist)
+		
 		aliases = api.getaliases(raptor_api.ALL) # ignore type
 		self.failUnlessEqual(len(aliases), 6)
 		
@@ -49,7 +53,7 @@
 	
 	def testConfig(self):
 		r = raptor.Raptor()
-		r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") )
+		r.cache.Load( generic_path.Join(r.home, "test", "configapi", "api.xml") )
 
 		api = raptor_api.Context(r)
 		
@@ -59,24 +63,59 @@
 			path = "C:/home/raptor/foo/bar"
 			
 		config = api.getconfig("buildme")
-		self.failUnlessEqual(config.fullname, "buildme")
+		self.failUnlessEqual(config.meaning, "buildme")
 		self.failUnlessEqual(config.outputpath, path)
 		
+		# metadata
+				
+		metadatamacros = map(lambda x: str(x.name+"="+x.value) if x.value else str(x.name), config.metadata.platmacros)
+		metadatamacros.sort()
+		results = ['SBSV2=_____SBSV2', '__GNUC__=3']
+		results.sort()
+		self.failUnlessEqual(metadatamacros, results)
+		
+		includepaths = map(lambda x: str(x.path), config.metadata.includepaths)
+		includepaths.sort()
+		expected_includepaths = [raptor_tests.ReplaceEnvs("$(EPOCROOT)/epoc32/include/variant"), 
+								raptor_tests.ReplaceEnvs("$(EPOCROOT)/epoc32/include"), "."]
+		expected_includepaths.sort()
+		self.failUnlessEqual(includepaths, expected_includepaths)
+		
+		preincludefile = str(config.metadata.preincludeheader.file)
+		self.failUnlessEqual(preincludefile, raptor_tests.ReplaceEnvs("$(EPOCROOT)/epoc32/include/variant/Symbian_OS.hrh"))
+		
+		# build
+		
+		sourcemacros = map(lambda x: str(x.name+"="+x.value) if x.value else str(x.name), config.build.sourcemacros)
+		results = ['__BBB__', '__AAA__', '__DDD__=first_value', '__CCC__', '__DDD__=second_value']
+		self.failUnlessEqual(sourcemacros, results)
+		
+		compilerpreincludefile = str(config.build.compilerpreincludeheader.file)
+		self.failUnlessEqual(compilerpreincludefile, raptor_tests.ReplaceEnvs("$(EPOCROOT)/epoc32/include/preinclude.h"))
+
+		expectedtypes = ["one", "two"]
+		expectedtypes.sort()
+		types = map(lambda t:t.name, config.build.targettypes)
+		types.sort()
+		self.failUnlessEqual(types, expectedtypes)
+
+		# general
+
 		config = api.getconfig("buildme.foo")
-		self.failUnlessEqual(config.fullname, "buildme.foo")
+		self.failUnlessEqual(config.meaning, "buildme.foo")
 		self.failUnlessEqual(config.outputpath, path)
 		
 		config = api.getconfig("s1")
-		self.failUnlessEqual(config.fullname, "buildme.foo")
+		self.failUnlessEqual(config.meaning, "buildme.foo")
 		self.failUnlessEqual(config.outputpath, path)
 		
 		config = api.getconfig("s2.product_A")
-		self.failUnlessEqual(config.fullname, "buildme.foo.bar.product_A")
+		self.failUnlessEqual(config.meaning, "buildme.foo.bar.product_A")
 		self.failUnlessEqual(config.outputpath, path)
 		
 	def testProducts(self):
 		r = raptor.Raptor()
-		r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") )
+		r.cache.Load( generic_path.Join(r.home, "test", "configapi", "api.xml") )
 
 		api = raptor_api.Context(r)
 		
@@ -84,6 +123,8 @@
 		self.failUnlessEqual(len(products), 2)
 		self.failUnlessEqual(set(["product_A","product_C"]),
 							 set(p.name for p in products))
+		productlist = [p.name for p in products] # verify that the list is sorted
+		self.failUnlessEqual(["product_A","product_C"], productlist)
 		
 # run all the tests