[SCM] ci-tooling packaging branch, master, updated. 7925b0bee5f866ec7fc1692a21b5a544d03711c9

Harald Sitter apachelogger-guest at moszumanska.debian.org
Wed Mar 25 09:40:36 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=7925b0b

The following commit has been merged in the master branch:
commit 7925b0bee5f866ec7fc1692a21b5a544d03711c9
Author: Harald Sitter <sitter at kde.org>
Date:   Wed Mar 25 10:40:31 2015 +0100

    prevent nil attributes when cmake parsing unstuiable logs
    
    instead set a validity attribute accordingly to allow inspection should
    things fail in the future
---
 kci/builder.rb            |  4 ++++
 lib/cmake_parser.rb       | 26 ++++++++++++++++++--------
 test/test_cmake_parser.rb | 10 +++++++++-
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/kci/builder.rb b/kci/builder.rb
index 6d34bba..396570b 100755
--- a/kci/builder.rb
+++ b/kci/builder.rb
@@ -224,6 +224,10 @@ end
 def puts_cmake(data, source_name)
   # Bit of compat code. Very lovely... NOT
   parser = CMakeParser.new(data)
+  unless parser.valid
+    puts_info 'CMakeParser could not parse the log correctly. Aborting parser.'
+    return
+  end
   missing = parser.missing
   warnings = parser.warnings
   disabled_features = parser.disabled_features
diff --git a/lib/cmake_parser.rb b/lib/cmake_parser.rb
index 2e91510..f0cf9cd 100644
--- a/lib/cmake_parser.rb
+++ b/lib/cmake_parser.rb
@@ -17,23 +17,32 @@ end
 class CMakeParser
   include BuildLogSegmenter
 
+  attr_reader :valid
   attr_reader :warnings
   attr_reader :missing
   attr_reader :disabled_features
 
   def initialize(data)
-    @data = segmentify(data, 'dh_auto_configure', 'dh_auto_build')
-    return if @data.empty?
-
+    @valid = false
     @missing = []
     @warnings = []
     @disabled_features = []
-    until @data.empty?
-      line = @data.shift
+
+    data = segmentify(data, 'dh_auto_configure', 'dh_auto_build')
+    return if data.empty?
+    parse(data)
+    @valid = true
+  end
+
+  private
+
+  def parse(data)
+    until data.empty?
+      line = data.shift
       if line.include?('The following OPTIONAL packages have not been found')
-        @missing += cmake_parse_summary(@data)
+        @missing += cmake_parse_summary(data)
       elsif line.include?('The following features have been disabled')
-        @disabled_features += cmake_parse_summary(@data)
+        @disabled_features += cmake_parse_summary(data)
       elsif line.include?('Could not find a package configuration file provided by')
         @missing += cmake_parse_package(line)
       elsif line.include?('CMake Warning')
@@ -78,7 +87,8 @@ class CMakeParser
     warn 'CMake Warning Parsing is disabled at this time!'
     return [] unless line.include?('CMake Warning')
     # Lines coming from MacroOptionalFindPackage (from old parsing).
-    return [] if line.include?('CMake Warning at /usr/share/kde4/apps/cmake/modules/MacroOptionalFindPackage.cmake')
+    return [] if line.include?('CMake Warning at /usr/share/kde4/apps/cmake/' \
+                               'modules/MacroOptionalFindPackage.cmake')
     # Lines coming from find_package (from old parsing).
     return [] if line.match(/CMake Warning at [^ :]+:\d+ \(find_package\)/)
     # Lines coming from warnings inside the actual CMakeLists.txt as those can
diff --git a/test/test_cmake_parser.rb b/test/test_cmake_parser.rb
index 9fe3177..aff18b9 100644
--- a/test/test_cmake_parser.rb
+++ b/test/test_cmake_parser.rb
@@ -9,26 +9,34 @@ class CMakeParserTest < TestCase
   end
 
   def test_init
-    CMakeParser.new(data)
+    parser = CMakeParser.new(data)
+    assert(!parser.valid)
+    assert_not_nil(parser.missing)
+    assert_not_nil(parser.warnings)
+    assert_not_nil(parser.disabled_features)
   end
 
   def test_missing_package
     parser = CMakeParser.new(data)
+    assert(parser.valid)
     assert_equal(%w(KF5Package), parser.missing)
   end
 
   def test_optional
     parser = CMakeParser.new(data)
+    assert(parser.valid)
     assert_equal(%w(Qt5TextToSpeech), parser.missing)
   end
 
   def test_warning
     parser = CMakeParser.new(data)
+    assert(parser.valid)
     assert_equal(%w(), parser.warnings)
   end
 
   def test_disabled_feature
     parser = CMakeParser.new(data)
+    assert(parser.valid)
     assert_equal(['XCB-CURSOR , Required for XCursor support'],
                  parser.disabled_features)
   end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list