groundcontrol 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,11 @@ module GroundControl
15
15
  repositories.each do |project, config|
16
16
 
17
17
  build_task = GroundControl::Builder.new(project, config)
18
- build_task.build
18
+ build_report = build_task.build
19
+
20
+ build_report.test_results.each do |test_result|
21
+ puts (test_result.failed? ? "FAIL" : "SUCCESS") + ": " + test_result.name
22
+ end
19
23
  end
20
24
 
21
25
  end
@@ -3,6 +3,7 @@ module GroundControl
3
3
  class BuildReport
4
4
 
5
5
  attr_reader :project_name, :branch, :testunit_success, :cucumber_success, :commit
6
+ attr_accessor :test_results
6
7
 
7
8
  def initialize(project_name, branch, testunit_success, cucumber_success, commit)
8
9
  @project_name = project_name
@@ -10,6 +11,7 @@ module GroundControl
10
11
  @testunit_success = testunit_success
11
12
  @cucumber_success = cucumber_success
12
13
  @commit = commit
14
+ @test_results = []
13
15
  end
14
16
 
15
17
  def success?
@@ -11,7 +11,8 @@ module GroundControl
11
11
  def initialize(project_name, config)
12
12
  @project_name = project_name
13
13
  @config = config
14
- @workspace = File.join("builds", project_name)
14
+ @workspace = File.expand_path(File.join("builds", project_name))
15
+ puts "Workspace: #{@workspace}"
15
16
  @build_directory = File.join(@workspace, "build")
16
17
  @reports_directory = File.join(@workspace, "reports")
17
18
  @git_url = @config['git']
@@ -27,6 +28,8 @@ module GroundControl
27
28
  test_report = run_tests_and_report()
28
29
 
29
30
  notify_campfire_of_build_result(test_report, @project_name, @repository)
31
+
32
+ return test_report
30
33
  end
31
34
 
32
35
  private
@@ -78,7 +81,17 @@ module GroundControl
78
81
  testunit_return_code = run_unit_tests()
79
82
  cucumber_return_code = run_cucumber_tests()
80
83
 
81
- return BuildReport.new(@project_name, @repository.head.name, testunit_return_code == 0, cucumber_return_code == 0, @repository.commits.first)
84
+ report = BuildReport.new(
85
+ @project_name,
86
+ @repository.head.name,
87
+ testunit_return_code == 0,
88
+ cucumber_return_code == 0,
89
+ @repository.commits.first)
90
+
91
+ report.test_results += TestResult.read_from_directory(File.join(@reports_directory, "features"))
92
+ report.test_results += TestResult.read_from_directory(File.join(@reports_directory, "testunit"))
93
+
94
+ return report
82
95
  end
83
96
 
84
97
  def clone_repository
@@ -6,8 +6,27 @@ module GroundControl
6
6
 
7
7
  attr_reader :name, :message
8
8
 
9
+ def self.read_from_directory(path_to_tests)
10
+ test_results_in_directory = []
11
+
12
+ Dir.chdir(path_to_tests)
13
+ Dir.glob("TEST-*.xml").each do |file|
14
+ f = File.open(File.join(path_to_tests, file))
15
+ doc = Nokogiri::XML(f)
16
+ f.close()
17
+ test_results_in_directory += read_tests_from_xml_document(doc)
18
+ end
19
+
20
+ return test_results_in_directory
21
+ end
22
+
9
23
  def self.read_from_xml(xml_string)
10
24
  doc = Nokogiri::XML.parse(xml_string)
25
+
26
+ return read_tests_from_xml_document(doc)
27
+ end
28
+
29
+ def self.read_tests_from_xml_document(doc)
11
30
  tests = []
12
31
 
13
32
  doc.xpath('//testcase').each do |testcase|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: groundcontrol
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michiel Sikkes