Merge fix
authortimothy.murphy@nokia.com
Sat, 06 Feb 2010 22:42:29 +0000
branchfix
changeset 195 309289285f0c
parent 190 2cca6dc0bb4b (current diff)
parent 194 369939723b79 (diff)
child 196 c0d1d904d868
Merge
sbsv2/raptor/RELEASE-NOTES.txt
--- a/sbsv2/raptor/RELEASE-NOTES.txt	Fri Feb 05 13:22:21 2010 +0000
+++ b/sbsv2/raptor/RELEASE-NOTES.txt	Sat Feb 06 22:42:29 2010 +0000
@@ -4,7 +4,7 @@
 
 Defect Fixes:
 - SF Bug 1569 - excessive recompilation in incremental tracecompiler builds
-
+- Better error messages for make-engine selection.  e.g. "sbs -e arm" will now produce a useful error message rather than a traceback. "arm" is a real variant but it's not a make engine.  In the past sbs would have tried to use it and would have failed with a complicated traceback. Also doesn't traceback for non-existent make engines.
 
 version 2.12.1
 
--- a/sbsv2/raptor/python/raptor.py	Fri Feb 05 13:22:21 2010 +0000
+++ b/sbsv2/raptor/python/raptor.py	Sat Feb 06 22:42:29 2010 +0000
@@ -1276,15 +1276,17 @@
 			if self.toolcheck != 'off':
 				self.CheckConfigs(buildUnitsToBuild)
 			else:
-				self.Info(" Not Checking Tool Versions")
+				self.Info("Not Checking Tool Versions")
 
 			self.AssertBuildOK()
 
 			# Setup a make engine.
 			if not self.maker:
-				self.maker = raptor_make.MakeEngine(self)
-				if self.maker == None:
-					self.Error("No make engine present")
+				try:
+					self.maker = raptor_make.MakeEngine(self, self.makeEngine)
+				except raptor_make.BadMakeEngineException,e:
+					self.Error("Unable to use make engine: %s " % str(e))
+					
 
 			self.AssertBuildOK()
 
--- a/sbsv2/raptor/python/raptor_data.py	Fri Feb 05 13:22:21 2010 +0000
+++ b/sbsv2/raptor/python/raptor_data.py	Sat Feb 06 22:42:29 2010 +0000
@@ -884,6 +884,21 @@
 			vars.append(m)
 		return [ BuildUnit(name=name, variants=vars) ]
 
+	def isDerivedFrom(self, progenitor, cache):
+		if self.name == progenitor:
+			return True
+
+		pname = self.extends
+		while pname is not None and pname is not '':
+			parent = cache.FindNamedVariant(pname)
+			if parent is None:
+				break
+			if parent.name == progenitor:
+				return True
+			pname = parent.extends
+
+		return False
+
 	def __str__(self):
 		s = "<var name='%s' extends='%s'>\n" % (self.name, self.extends)
 		for op in self.ops:
@@ -936,7 +951,7 @@
 	def Valid(self):
 		return self.name and self.meaning
 
-	def GenerateBuildUnits(self, cache):
+	def Resolve(self, cache):
 		if not self.variants:
 			missing_variants = []
 			for r in self.varRefs:
@@ -948,6 +963,9 @@
 			if len(missing_variants) > 0:
 				raise MissingVariantException("Missing variants '%s'", " ".join(missing_variants))
 
+	def GenerateBuildUnits(self, cache):
+		self.Resolve(cache)
+
 		name = self.name
 
 		for v in self.modifiers:
@@ -955,6 +973,12 @@
 
 		return [ BuildUnit(name=name, variants=self.variants + self.modifiers) ]
 
+	def isDerivedFrom(self, progenitor, cache):
+		self.Resolve(cache)
+		if len(self.variants) == 1:
+			return self.variants[0].isDerivedFrom(progenitor,cache)
+		else:
+			return False
 
 class AliasRef(Reference):
 
--- a/sbsv2/raptor/python/raptor_make.py	Fri Feb 05 13:22:21 2010 +0000
+++ b/sbsv2/raptor/python/raptor_make.py	Sat Feb 06 22:42:29 2010 +0000
@@ -33,18 +33,19 @@
 from xml.sax.saxutils import escape
 
 
+class BadMakeEngineException(Exception):
+	pass
+
 # raptor_make module classes
 
 class MakeEngine(object):
 
-	def __init__(self, Raptor):
+	def __init__(self, Raptor, engine):
 		self.raptor = Raptor
 		self.valid = True
 		self.descrambler = None
 		self.descrambler_started = False
 
-		engine = Raptor.makeEngine
-		
 		# look for an alias first as this gives end-users a chance to modify
 		# the shipped variant rather than completely replacing it.
 		if engine in Raptor.cache.aliases:
@@ -52,8 +53,10 @@
 		elif engine in Raptor.cache.variants:
 			avar = Raptor.cache.FindNamedVariant(engine)
 		else:
-			Raptor.Error("No settings found for build engine '%s'", engine)
-			return
+			raise BadMakeEngineException("'%s' does not appear to be a make engine - no settings found for it" % engine)
+
+		if not avar.isDerivedFrom("make_engine", Raptor.cache):
+			raise BadMakeEngineException("'%s' is not a build engine (it's a variant but it does not extend 'make_engine')" % engine)
 					
 		# find the variant and extract the values
 		try:
@@ -105,14 +108,13 @@
 				self.selectors = []
 
 		except KeyError:
-			Raptor.Error("Bad '%s' configuration found.", engine)
 			self.valid = False
-			return
+			raise BadMakeEngineException("Bad '%s' configuration found." % engine)
 
 		# there must at least be a build command...
 		if not self.buildCommand:
-				Raptor.Error("No build command for '%s'", engine)
-				self.valid = False
+			self.valid = False
+			raise BadMakeEngineException("No build command for '%s'"% engine)
 
 
 		if self.usetalon:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/test/smoke_suite/input_validation.py	Sat Feb 06 22:42:29 2010 +0000
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: 
+#
+
+from raptor_tests import SmokeTest
+
+def run():
+	t = SmokeTest()
+	t.description = "Set of tests for commandline option validation e.g. checking that the specified make engine exists"
+	
+	t.mustmatch = ["Unable to use make engine: 'amakeenginethatdoesnotexist' does not appear to be a make engine - no settings found for it"]
+	
+	t.usebash = True
+	t.errors = 1
+	t.returncode = 1
+	t.exceptions = 0
+	base_command = "sbs -b smoke_suite/test_resources/simple/bld.inf -f ${SBSLOGFILE} -m ${SBSMAKEFILE}"
+	
+	t.id = "114a"
+	t.name = "validate_makeengine_nonexist"
+	t.command = base_command + " -e amakeenginethatdoesnotexist"
+
+	t.run()
+
+	t.id = "114b"
+	t.mustmatch = ["Unable to use make engine: 'arm' is not a build engine \(it's a variant but it does not extend 'make_engine'"]
+	t.name = "validate_makeengine_is_a_non_makenegine_variant"
+	t.command = base_command + " -e arm"
+	t.run()
+	
+	t.id = "114"
+	t.name = "input_validation"
+	t.print_result()
+	return t