From: <jh...@us...> - 2009-04-02 00:20:23
|
Revision: 76 http://etch.svn.sourceforge.net/etch/?rev=76&view=rev Author: jheiss Date: 2009-04-02 00:20:11 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Fix handling of operator comparisons in attribute filtering. Improve test for same. Rescue any exceptions in configfilter! where it is called by generate file so that we can insert the name of the config.xml file that we were handling when the exception occurred. This should help the user with debugging. Same logic as the exception catch/re-raise that occurs when running user scripts. Modified Paths: -------------- trunk/server/lib/etchserver.rb trunk/test/attributes.rb Modified: trunk/server/lib/etchserver.rb =================================================================== --- trunk/server/lib/etchserver.rb 2009-02-06 19:47:29 UTC (rev 75) +++ trunk/server/lib/etchserver.rb 2009-04-02 00:20:11 UTC (rev 76) @@ -344,7 +344,11 @@ config_xml = LibXML::XML::Document.file(config_xml_file) # Filter the config.xml file by looking for attributes - configfilter!(config_xml.root) + begin + configfilter!(config_xml.root) + rescue Exception => e + raise e.exception("Error filtering config.xml for #{file}:\n" + e.message) + end # Validate the filtered file against config.dtd if !config_xml.validate(@config_dtd) @@ -939,7 +943,7 @@ operator = $1 valueversion = Version.new($2) compversion = Version.new(comp) - if valueversion.send(operator.to_sym, compversion) + if compversion.send(operator.to_sym, valueversion) result = true end # Regular expressions Modified: trunk/test/attributes.rb =================================================================== --- trunk/test/attributes.rb 2009-02-06 19:47:29 UTC (rev 75) +++ trunk/test/attributes.rb 2009-04-02 00:20:11 UTC (rev 76) @@ -481,7 +481,17 @@ # Version fact operator comparison # testname = 'version fact operator comparison' - + + # Try to make up a subset of operatingsystemrelease so that we really + # test the operator functionality and not just equality. I.e. if osrel + # is 2.5.1 we'd like to extract 2.5 + osrelsubset = osrel + osrelparts = osrel.split('.') + if osrelparts.length > 1 + osrelparts.pop + osrelsubset = osrelparts.join('.') + end + FileUtils.mkdir_p("#{@repodir}/source/#{@targetfile}") File.open("#{@repodir}/source/#{@targetfile}/config.xml", 'w') do |file| file.puts <<-EOF @@ -489,7 +499,7 @@ <file> <warning_file/> <source> - <plain operatingsystemrelease=">=#{osrel}">source</plain> + <plain operatingsystemrelease=">=#{osrelsubset}">source</plain> </source> </file> </config> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |