minitest-ci 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2729a8517ac10d9febe0425d40fc263a6ec3d6c
4
- data.tar.gz: 024571f398527def3e6ddcd37618b85c363bd8a6
3
+ metadata.gz: 7df74b27d06a7fc3c130ff4948fa7409006fffd9
4
+ data.tar.gz: 0f475b81387862ff375e1de9e790239c6bbcd656
5
5
  SHA512:
6
- metadata.gz: 28d66efb28c6f0d529d5cb1eabc91c597d2e3d66a46dd10b3908a3f8ac299025fdd0033903919fbdd2b4a82f824e1366afc084505c83dfab422aa6ad2b767542
7
- data.tar.gz: 6bea3a25b0aeb756e27c51e5b5df7e7ccadb36ddde52a6b7f355375bd39be65361ec9462a1eb4f8a8869897977d4e17c68caef9a6fd21a7f1a1946be2f9de785
6
+ metadata.gz: f3602c8752a1b60b63b4c403d572c6e45932d56fd8014efb578298c4df55890721baaad6bf66a94ce2f985b30eee8adee285d1464adf0bebab88b08b5b909eaf
7
+ data.tar.gz: faf0bbac59b3b69b0c38b917defd428fddd7189cd65aef264100d223eb55dcec9d41211c444e9233ae16d92d954eb75cde83267cdccd1e085e6b388e2cb3b84d
data/README.rdoc CHANGED
@@ -6,20 +6,23 @@
6
6
 
7
7
  == DESCRIPTION:
8
8
 
9
- Minitest reporter plugin for CircleCI
9
+ Minitest reporter plugin for [CircleCI](https://circleci.com/).
10
10
 
11
11
  This gem was made possible by YP.com
12
12
 
13
- Records test results and generates XML files (for junit hudson plugin
14
- for example) at the end of the test run.
13
+ Records test results and generates XML files at the end of the test run.
14
+
15
+ These results can be plugged into, for example, Hudson or Jenkins.
16
+ This format is also the default used by CircleCI.
15
17
 
16
18
  == USAGE:
17
19
 
18
20
  In order to use this gem, add it to your Gemfile:
19
21
 
20
- gem "minitest-cli"
22
+ gem "minitest-ci"
21
23
 
22
- To make integration with CircleCI easier, make sure you have a ":test" task defined. You can do simply by adding the following to your Rakefile:
24
+ To make integration with CircleCI easier, make sure you have a ":test" task defined.
25
+ You can do this by simply adding the following to your Rakefile:
23
26
 
24
27
  require 'rake/testtask'
25
28
 
@@ -39,13 +42,31 @@ To configure the test output folder, use the "--ci-dir=" option, setting it in
39
42
  TESTOPTS. On CircleCI, you might want to use something like this in your
40
43
  circle.yml:
41
44
 
45
+ machine:
46
+ environment:
47
+ TESTOPTS: "--ci-dir=$CIRCLE_TEST_REPORTS/reports"
42
48
  test:
43
49
  override:
44
- - bundle exec rake test TESTOPTS="--ci-dir=$CIRCLE_TEST_REPORTS/reports":
50
+ - bundle exec rake test:
45
51
  parallel: true
46
52
  files:
47
53
  - test/**/*.rb
48
54
 
55
+ Alternatively, you can add the following code to your test runner setup:
56
+
57
+ # test/helper.rb
58
+ require 'minitest'
59
+ require 'minitest/autorun'
60
+ require 'minitest/ci'
61
+
62
+ if ENV["CIRCLECI"]
63
+ Minitest::Ci.report_dir = "#{ENV["CIRCLE_TEST_REPORTS"]}/reports"
64
+ end
65
+
66
+ class MiniTest::Test
67
+ # include other helpers, etc
68
+ end
69
+
49
70
 
50
71
  **NOTE**: The report directory is cleaned between test runs. To disable:
51
72
 
@@ -0,0 +1,2 @@
1
+ require 'minitest'
2
+ require 'minitest/ci'
data/lib/minitest/ci.rb CHANGED
@@ -2,15 +2,11 @@ require 'fileutils'
2
2
  require 'cgi'
3
3
 
4
4
  module Minitest
5
- class Ci
6
-
7
- VERSION = '3.1.0'
8
-
5
+ class Ci < Reporter
9
6
  class << self
10
7
 
11
8
  ##
12
- # Accessor method to change the report dir if you don't like the
13
- # defaults.
9
+ # Change the report directory. (defaults to "test/reports")
14
10
 
15
11
  attr_accessor :report_dir
16
12
 
@@ -18,6 +14,9 @@ module Minitest
18
14
  # Clean the report_dir between test runs? (defaults to true)
19
15
 
20
16
  attr_accessor :clean
17
+
18
+ ##
19
+ # Change the working directory. (defaults to `$PWD`)
21
20
  attr_accessor :working_dir
22
21
  end
23
22
 
@@ -48,14 +47,16 @@ module Minitest
48
47
  results[result.class] << result
49
48
  end
50
49
 
50
+ ##
51
+ # Generate test report
51
52
  def report
52
53
  io.puts
53
- io.puts 'generating ci files'
54
+ io.puts '[Minitest::CI] Generating test report in JUnit XML format...'
54
55
 
55
56
  Dir.chdir report_dir do
56
- results.each do |name, resultz|
57
- File.open "TEST-#{CGI.escape(name.to_s)}.xml"[0, 255], "w" do |f|
58
- f.puts generate_results name, resultz
57
+ results.each do |name, result|
58
+ File.open(report_name(name), "w") do |f|
59
+ f.puts( generate_results(name, result) )
59
60
  end
60
61
  end
61
62
  end
@@ -72,7 +73,7 @@ module Minitest
72
73
  results.each do |result|
73
74
  total_time += result.time
74
75
  assertions += result.assertions
75
- # p result.failure.class
76
+
76
77
  case result.failure
77
78
  when Skip
78
79
  skips += 1
@@ -83,7 +84,7 @@ module Minitest
83
84
  end
84
85
  end
85
86
 
86
- base = self.class.working_dir + '/'
87
+ base = working_dir + '/'
87
88
  xml = []
88
89
 
89
90
  xml << '<?xml version="1.0" encoding="UTF-8"?>'
@@ -116,6 +117,10 @@ module Minitest
116
117
  xml
117
118
  end
118
119
 
120
+ def working_dir
121
+ options.fetch(:working_dir, self.class.working_dir)
122
+ end
123
+
119
124
  def report_dir
120
125
  options.fetch(:ci_dir, self.class.report_dir)
121
126
  end
@@ -124,5 +129,8 @@ module Minitest
124
129
  options.fetch(:ci_clean, self.class.clean)
125
130
  end
126
131
 
132
+ def report_name(name)
133
+ "TEST-#{CGI.escape(name.to_s.gsub(/\W+/, '_'))}.xml"[0, 255]
134
+ end
127
135
  end
128
136
  end
@@ -14,6 +14,10 @@ module Minitest
14
14
  opts.on "--[no-]ci-clean", "Clean the CI report dir in between test runs. Default #{Ci.clean}" do |clean|
15
15
  options[:ci_clean] = clean
16
16
  end
17
+
18
+ opts.on "--working-dir DIR", "Set the working dir. Default to #{Ci.working_dir}" do |dir|
19
+ options[:working_dir] = dir
20
+ end
17
21
  end
18
22
 
19
23
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
+ - zzak
7
8
  - bhenderson
8
9
  - notnoop
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2016-09-23 00:00:00.000000000 Z
13
+ date: 2017-03-14 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: minitest
@@ -18,9 +19,6 @@ dependencies:
18
19
  - - ">="
19
20
  - !ruby/object:Gem::Version
20
21
  version: 5.0.6
21
- - - "~>"
22
- - !ruby/object:Gem::Version
23
- version: '5.0'
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,9 +26,6 @@ dependencies:
28
26
  - - ">="
29
27
  - !ruby/object:Gem::Version
30
28
  version: 5.0.6
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '5.0'
34
29
  - !ruby/object:Gem::Dependency
35
30
  name: bundler
36
31
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +82,20 @@ dependencies:
87
82
  - - ">="
88
83
  - !ruby/object:Gem::Version
89
84
  version: 2.4.2
85
+ - !ruby/object:Gem::Dependency
86
+ name: json
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 2.0.0
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 2.0.0
90
99
  - !ruby/object:Gem::Dependency
91
100
  name: ZenTest
92
101
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +119,7 @@ extra_rdoc_files: []
110
119
  files:
111
120
  - README.rdoc
112
121
  - lib/autotest/minitest_ci.rb
122
+ - lib/minitest-ci.rb
113
123
  - lib/minitest/ci.rb
114
124
  - lib/minitest/ci_plugin.rb
115
125
  homepage: https://github.com/circleci/minitest-ci
@@ -131,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
141
  version: 1.3.6
132
142
  requirements: []
133
143
  rubyforge_project:
134
- rubygems_version: 2.6.6
144
+ rubygems_version: 2.6.8
135
145
  signing_key:
136
146
  specification_version: 4
137
147
  summary: Minitest JUnit XML formatter