sbsv2/raptor/test/unit_suite/raptor_xml_unit.py
changeset 18 de5b887c98f7
parent 13 c327db0664bb
child 28 b8fa7dfeeaa1
--- a/sbsv2/raptor/test/unit_suite/raptor_xml_unit.py	Tue May 18 19:36:14 2010 +0100
+++ b/sbsv2/raptor/test/unit_suite/raptor_xml_unit.py	Fri Jun 04 13:09:28 2010 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of the License "Eclipse Public License v1.0"
@@ -17,15 +17,34 @@
 #
 
 import os
+import generic_path
 import raptor
-import generic_path
 import raptor_xml
 import unittest
 
 class TestRaptorXML(unittest.TestCase):
+		
+	class Logger(object):
+		# Basic custom logger class to store errors (and only errors) for test checks
+
+		def __init__(self):	
+			self.errors = []
+					
+		def Error(self, format, *extras, **attributes):
+			self.errors.append(format % extras)
+
+		def Info(self, format, *extras, **attributes):
+			return
+			
+		def InfoDiscovery(self, object_type, count):
+			return
+		
+		def Clear(self):
+			del self.errors[:]
+			
 	
 	def setUp(self):
-		self.__logger = raptor.Raptor()
+		self.__logger = TestRaptorXML.Logger()
 		self.__nullSysDefRoot = generic_path.Path("smoke_suite/test_resources")
 		self.__sysDefRoot = generic_path.Join(os.environ[raptor.env],"test/smoke_suite/test_resources")
 		self.__sysDefFileRoot = generic_path.Join(os.environ[raptor.env], "test/metadata/system")
@@ -64,8 +83,11 @@
 		systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_3.0.0.xml"), self.__sysDefRoot)
 		self.__compareFileLists([], systemModel.GetAllComponents())
 				
-		
+		self.__logger.Clear()
 		systemModel = raptor_xml.SystemModel(self.__logger, generic_path.Join(self.__sysDefFileRoot, "system_definition_multi_layers.xml"), self.__sysDefRoot)
+		self.assertTrue(len(self.__logger.errors) == 0)
+
+		# Confirm components returned from layers are correct
 
 		expectedBldInfs = [ generic_path.Join(self.__sysDefRoot, "simple/bld.inf"),\
 							generic_path.Join(self.__sysDefRoot, "simple_dll/bld.inf"),\
@@ -74,7 +96,8 @@
 						    generic_path.Join(self.__sysDefRoot, "simple_implib/bld.inf"),\
 						    generic_path.Join(self.__sysDefRoot, "simple_lib/bld.inf"),\
 						    generic_path.Join(self.__sysDefRoot, "simple_stringtable/bld.inf"),\
-						    generic_path.Join(self.__sysDefRoot, "simple_test/bld.inf")]
+						    generic_path.Join(self.__sysDefRoot, "simple_test/bld.inf"),\
+						    generic_path.Join(self.__sysDefRoot, "simple_plugin/bld.inf")]
 		self.__compareFileLists(expectedBldInfs, systemModel.GetAllComponents())
 	
 		expectedBldInfs = [ generic_path.Join(self.__sysDefRoot, "simple_export/bld.inf"),\
@@ -85,6 +108,23 @@
 				
 		self.__compareFileLists([], systemModel.GetLayerComponents("Sixth Layer"))
 		
+		# Check that the overall "buildability" of layers is returned correctly
+		# Note that a layer is still buildable if some bld.infs in it are missing as long as at least 1 exists
+		# However, errors should always be generated for missing bld.infs when a layer is checked
+		
+		self.assertTrue(systemModel.IsLayerBuildable("First Layer"))		
+		self.assertFalse(systemModel.IsLayerBuildable("Sixth Layer"))
+		
+		self.__logger.Clear()
+		self.assertTrue(systemModel.IsLayerBuildable("Seventh Layer"))
+		self.assertTrue(len(self.__logger.errors) == 1)
+		sbsHome = os.environ["SBS_HOME"]
+		sysDefPath = sbsHome + "/test/metadata/system/system_definition_multi_layers.xml"
+		sysDefPath = sysDefPath.replace("\\","/")
+		bldInfPath = sbsHome + "/test/smoke_suite/test_resources/does_not_existbld.inf"
+		bldInfPath = bldInfPath.replace("\\","/")
+		self.assertEquals(self.__logger.errors[0],
+		  ("System Definition layer \"Seventh Layer\" from system definition file \"%s\" refers to non existent bld.inf file %s" % (sysDefPath, bldInfPath)))
 				
 		# Probably redundant, but return local environment (at least its dictionary) to pre-test state
 		os.environ["SOURCEROOT"] = sourceroot