blinka-reporter 0.7.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/main.yml +3 -3
- data/.husky/pre-commit +4 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/README.md +9 -8
- data/Rakefile +4 -4
- data/blinka_reporter.gemspec +26 -28
- data/lib/blinka_reporter/cli.rb +6 -35
- data/lib/blinka_reporter/client.rb +23 -26
- data/lib/blinka_reporter/error.rb +2 -1
- data/lib/blinka_reporter/minitest_adapter.rb +10 -7
- data/lib/blinka_reporter/tap.rb +11 -11
- data/lib/blinka_reporter/version.rb +1 -1
- data/lib/blinka_reporter.rb +4 -3
- data/lib/minitest/blinka_plugin.rb +26 -15
- data/package.json +9 -7
- data/yarn.lock +178 -428
- metadata +22 -33
- data/lib/blinka_reporter/blinka.rb +0 -172
- data/lib/blinka_reporter/config.rb +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3cf58900ce1f0eb96c9feb8dc5468c2e4f51c80b8f06c501988439d2a9b241b
|
|
4
|
+
data.tar.gz: c61e2b22ae72069c8355b277b9f52ebddedfc59217e8d2ac9595fd2ce73b095f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 502fc7e5acbcf80175728d8bf11185437291a986e6f895c262bcd0a025448340518d6c7a05643b911763b31d569f851fe037080f5b636e2e15330840c0173549
|
|
7
|
+
data.tar.gz: 34348eb00a80ccf7e752d5d0bb628a042b6c96ac431a332726e516d73bd27acfe4da3018e3cd80acfea36ff204fafefc3917d119302b54848a9e22e1caba29cd
|
data/.github/dependabot.yml
CHANGED
data/.github/workflows/main.yml
CHANGED
|
@@ -10,11 +10,11 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
|
-
ruby: ["2
|
|
13
|
+
ruby: ["3.2", "3.3", "3.4", "4.0"]
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
16
|
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@
|
|
17
|
+
uses: actions/checkout@v6
|
|
18
18
|
|
|
19
19
|
- name: Setup Ruby
|
|
20
20
|
uses: ruby/setup-ruby@v1
|
|
@@ -49,7 +49,7 @@ jobs:
|
|
|
49
49
|
|
|
50
50
|
- name: Blinka - Archive
|
|
51
51
|
if: always()
|
|
52
|
-
uses: actions/upload-artifact@
|
|
52
|
+
uses: actions/upload-artifact@v4
|
|
53
53
|
with:
|
|
54
54
|
name: blinka-${{ strategy.job-index }}
|
|
55
55
|
path: |
|
data/.husky/pre-commit
ADDED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.4.8
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.4.8
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.0] - 2026-01-20
|
|
11
|
+
|
|
12
|
+
- Support Minitest 6.
|
|
13
|
+
|
|
14
|
+
## [0.8.0] - 2023-03-04
|
|
15
|
+
|
|
16
|
+
- Removes support for reporting to Blinka, removing the need for httparty.
|
|
17
|
+
- Makes `Capybara.save_path` relative to the current working directory for images
|
|
18
|
+
|
|
10
19
|
## [0.7.2] - 2023-02-19
|
|
11
20
|
|
|
12
21
|
- Adds support for `BLINKA_APPEND=true` to append to existing JSON-files.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -16,7 +16,7 @@ gem install blinka-reporter
|
|
|
16
16
|
or add to your Gemfile
|
|
17
17
|
|
|
18
18
|
```ruby
|
|
19
|
-
gem 'blinka-reporter', '~> 0.7.
|
|
19
|
+
gem 'blinka-reporter', '~> 0.7.2'
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Which ruby testing frameworks are supported?
|
|
@@ -34,6 +34,12 @@ Blinka is a web service developed by [@davidwessman](https://github.com/davidwes
|
|
|
34
34
|
|
|
35
35
|
### Minitest
|
|
36
36
|
|
|
37
|
+
Minitest 6 no longer auto-loads plugins by default, so make sure the Blinka plugin is loaded in your test helper (eg `test/test_helper.rb`):
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
require "minitest/blinka_plugin"
|
|
41
|
+
```
|
|
42
|
+
|
|
37
43
|
```sh
|
|
38
44
|
BLINKA_PATH=./tests.json bundle exec rails test
|
|
39
45
|
```
|
|
@@ -48,11 +54,6 @@ Make sure [rspec_junit_formatter](https://github.com/sj26/rspec_junit_formatter)
|
|
|
48
54
|
bundle exec rspec --formatter RspecJunitFormatter --out ./rspec.xml
|
|
49
55
|
```
|
|
50
56
|
|
|
51
|
-
## How to send report to Blinka?
|
|
52
|
-
|
|
53
|
-
1. Output your test results as described [above](#how-to-generate-test-report-in-the-right-format).
|
|
54
|
-
1. `bundle exec blinka_reporter --path {./blinka_results.json,./rspec.xml} --blinka --team-id <BLINKA_TEAM_ID> --team-secret <BLINKA_TEAM_SECRET> --repository davidwessman/blinka_reporter`
|
|
55
|
-
|
|
56
57
|
## How can I send report in Github Action?
|
|
57
58
|
|
|
58
59
|
Add a step to your Github Action Workflow after running tests:
|
|
@@ -74,7 +75,7 @@ Add a step to your Github Action Workflow after running tests:
|
|
|
74
75
|
// Blinka will automatically fetch the results when the Github Action Workflow is finished.
|
|
75
76
|
- name: Archive results for Blinka
|
|
76
77
|
if: always()
|
|
77
|
-
uses: actions/upload-artifact@
|
|
78
|
+
uses: actions/upload-artifact@v4
|
|
78
79
|
with:
|
|
79
80
|
name: blinka-${{ strategy.job-index }}
|
|
80
81
|
path: |
|
|
@@ -115,7 +116,7 @@ Output the test results to different paths with `BLINKA_PATH`.
|
|
|
115
116
|
|
|
116
117
|
- name: Tests
|
|
117
118
|
env:
|
|
118
|
-
|
|
119
|
+
BLINKA_PATH: ./tests.json
|
|
119
120
|
run: bundle exec rails test
|
|
120
121
|
|
|
121
122
|
- name: Archive results for Blinka
|
data/Rakefile
CHANGED
data/blinka_reporter.gemspec
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative "lib/blinka_reporter/version"
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
|
-
gem.authors = [
|
|
4
|
+
gem.authors = ["David Wessman"]
|
|
5
5
|
gem.description =
|
|
6
|
-
|
|
7
|
-
gem.email =
|
|
8
|
-
gem.homepage =
|
|
9
|
-
gem.license =
|
|
10
|
-
gem.summary =
|
|
6
|
+
"Use to format test results from Minitest to use with Blinka."
|
|
7
|
+
gem.email = "david@wessman.co"
|
|
8
|
+
gem.homepage = "https://github.com/davidwessman/blinka_reporter"
|
|
9
|
+
gem.license = "MIT"
|
|
10
|
+
gem.summary = "Format tests for Blinka"
|
|
11
11
|
|
|
12
12
|
gem.metadata = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
"homepage_uri" => "https://github.com/davidwessman/blinka_reporter",
|
|
14
|
+
"bug_tracker_uri" =>
|
|
15
|
+
"https://github.com/davidwessman/blinka_reporter/issues",
|
|
16
|
+
"documentation_uri" => "https://github.com/davidwessman/blinka_reporter",
|
|
17
|
+
"changelog_uri" =>
|
|
18
|
+
"https://github.com/davidwessman/blinka_reporter/main/CHANGELOG.md",
|
|
19
|
+
"source_code_uri" => "https://github.com/davidwessman/blinka_reporter",
|
|
20
|
+
"rubygems_mfa_required" => "true"
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
gem.files =
|
|
24
|
-
Dir.chdir(File.expand_path(
|
|
25
|
-
`git ls-files -z
|
|
26
|
-
.split("\x0")
|
|
24
|
+
Dir.chdir(File.expand_path("..", __FILE__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0")
|
|
27
26
|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
28
27
|
end
|
|
29
|
-
gem.name =
|
|
28
|
+
gem.name = "blinka-reporter"
|
|
30
29
|
gem.version = BlinkaReporter::VERSION
|
|
31
|
-
gem.executables = [
|
|
32
|
-
gem.require_path = [
|
|
30
|
+
gem.executables = ["blinka_reporter"]
|
|
31
|
+
gem.require_path = ["lib"]
|
|
33
32
|
|
|
34
|
-
gem.add_dependency(
|
|
35
|
-
gem.
|
|
36
|
-
gem.add_development_dependency(
|
|
37
|
-
gem.add_development_dependency(
|
|
38
|
-
gem.add_development_dependency(
|
|
39
|
-
gem.add_development_dependency(
|
|
40
|
-
gem.add_development_dependency('webmock', '~> 3.11')
|
|
33
|
+
gem.add_dependency("ox", "~> 2")
|
|
34
|
+
gem.add_development_dependency("dotenv", "~> 3.0.0")
|
|
35
|
+
gem.add_development_dependency("minitest", ">= 5", "< 7")
|
|
36
|
+
gem.add_development_dependency("mocha", "~> 2.0")
|
|
37
|
+
gem.add_development_dependency("rake", "~> 13")
|
|
38
|
+
gem.add_development_dependency("standard")
|
|
41
39
|
end
|
data/lib/blinka_reporter/cli.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "blinka_reporter/client"
|
|
2
|
+
require "blinka_reporter/version"
|
|
3
3
|
|
|
4
4
|
module BlinkaReporter
|
|
5
5
|
class Cli
|
|
6
6
|
def self.run(argv)
|
|
7
|
-
if (argv.index(
|
|
7
|
+
if (argv.index("--help") || -1) >= 0
|
|
8
8
|
puts(<<~EOS)
|
|
9
9
|
blinka_reporter version #{BlinkaReporter::VERSION}
|
|
10
10
|
|
|
@@ -14,46 +14,17 @@ module BlinkaReporter
|
|
|
14
14
|
- ./rspec.xml from https://github.com/sj26/rspec_junit_formatter
|
|
15
15
|
|
|
16
16
|
--tap: Flag for outputting test results in TAP-protocol, helpful on Heroku CI
|
|
17
|
-
--blinka: Flag for reporting test results to blinka.app, requires also supplying:
|
|
18
|
-
- --team-id
|
|
19
|
-
- --team-secret
|
|
20
|
-
- --repository
|
|
21
|
-
- --commit
|
|
22
|
-
--team-id <team-id>: Blinka team id, only used with --blinka
|
|
23
|
-
--team-secret <team-secret>: Blinka team secret, only used with --blinka
|
|
24
|
-
--commit <commit>: The commit hash to report
|
|
25
|
-
--tag <tag>: The tag for the run, for example to separate a test matrix
|
|
26
|
-
--repository <repository>: The Github repository
|
|
27
|
-
--host <host>: Override Blink host to send report
|
|
28
|
-
|
|
29
17
|
EOS
|
|
30
18
|
return 0
|
|
31
19
|
end
|
|
32
20
|
|
|
33
|
-
tap = (argv.index(
|
|
34
|
-
|
|
35
|
-
paths = argv_value_for(argv, '--path')
|
|
21
|
+
tap = (argv.index("--tap") || -1) >= 0
|
|
36
22
|
|
|
37
|
-
|
|
38
|
-
commit = argv_value_for(argv, '--commit')&.first
|
|
39
|
-
repository = argv_value_for(argv, '--repository')&.first
|
|
40
|
-
tag = argv_value_for(argv, '--tag')&.first
|
|
41
|
-
team_id = argv_value_for(argv, '--team-id')&.first
|
|
42
|
-
team_secret = argv_value_for(argv, '--team-secret')&.first
|
|
43
|
-
host = argv_value_for(argv, '--host')&.first
|
|
23
|
+
paths = argv_value_for(argv, "--path")
|
|
44
24
|
|
|
45
25
|
client = BlinkaReporter::Client.new
|
|
46
26
|
data = client.parse(paths: paths)
|
|
47
|
-
|
|
48
|
-
BlinkaReporter::Config.new(
|
|
49
|
-
tag: tag,
|
|
50
|
-
commit: commit,
|
|
51
|
-
team_id: team_id,
|
|
52
|
-
team_secret: team_secret,
|
|
53
|
-
repository: repository,
|
|
54
|
-
host: host
|
|
55
|
-
)
|
|
56
|
-
client.report(data: data, config: config, tap: tap, blinka: blinka)
|
|
27
|
+
client.report(data: data, tap: tap)
|
|
57
28
|
end
|
|
58
29
|
|
|
59
30
|
def self.argv_value_for(argv, option_name)
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "ox"
|
|
2
|
+
require "json"
|
|
3
3
|
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require 'blinka_reporter/error'
|
|
7
|
-
require 'blinka_reporter/tap'
|
|
4
|
+
require "blinka_reporter/error"
|
|
5
|
+
require "blinka_reporter/tap"
|
|
8
6
|
|
|
9
7
|
module BlinkaReporter
|
|
10
8
|
class Client
|
|
11
9
|
def parse(paths: nil)
|
|
12
|
-
paths ||= [
|
|
10
|
+
paths ||= ["./blinka_results.json"]
|
|
13
11
|
paths = Array(paths)
|
|
14
12
|
paths.each do |path|
|
|
15
13
|
unless File.exist?(path)
|
|
@@ -22,9 +20,9 @@ module BlinkaReporter
|
|
|
22
20
|
|
|
23
21
|
merge_results(
|
|
24
22
|
paths.map do |path|
|
|
25
|
-
if path.end_with?(
|
|
23
|
+
if path.end_with?(".xml")
|
|
26
24
|
parse_xml(path: path)
|
|
27
|
-
elsif path.end_with?(
|
|
25
|
+
elsif path.end_with?(".json")
|
|
28
26
|
parse_json(path: path)
|
|
29
27
|
else
|
|
30
28
|
raise(
|
|
@@ -36,16 +34,15 @@ module BlinkaReporter
|
|
|
36
34
|
)
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
def report(data:,
|
|
37
|
+
def report(data:, tap: false)
|
|
40
38
|
BlinkaReporter::Tap.report(data) if tap
|
|
41
|
-
BlinkaReporter::Blinka.report(config: config, data: data) if blinka
|
|
42
39
|
0
|
|
43
40
|
end
|
|
44
41
|
|
|
45
42
|
private
|
|
46
43
|
|
|
47
44
|
def merge_results(data_array)
|
|
48
|
-
data = {
|
|
45
|
+
data = {total_time: 0, nbr_tests: 0, nbr_assertions: 0, results: []}
|
|
49
46
|
data_array.each do |result|
|
|
50
47
|
data[:total_time] += result[:total_time] || 0
|
|
51
48
|
data[:nbr_tests] += result[:nbr_tests] || 0
|
|
@@ -56,18 +53,18 @@ module BlinkaReporter
|
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
def parse_json(path:)
|
|
59
|
-
JSON.parse(File.
|
|
56
|
+
JSON.parse(File.read(path), symbolize_names: true)
|
|
60
57
|
end
|
|
61
58
|
|
|
62
59
|
def parse_xml(path:)
|
|
63
|
-
data = Ox.load_file(path, {
|
|
60
|
+
data = Ox.load_file(path, {symbolize_keys: true, skip: :skip_none})
|
|
64
61
|
test_suite = data.root
|
|
65
|
-
unless test_suite.name ==
|
|
62
|
+
unless test_suite.name == "testsuite"
|
|
66
63
|
raise("Root element is not <testsuite>, instead #{test_suite.name}")
|
|
67
64
|
end
|
|
68
65
|
|
|
69
|
-
properties = test_suite.nodes.select { |node| node.name ==
|
|
70
|
-
test_cases = test_suite.nodes.select { |node| node.name ==
|
|
66
|
+
properties = test_suite.nodes.select { |node| node.name == "properties" }
|
|
67
|
+
test_cases = test_suite.nodes.select { |node| node.name == "testcase" }
|
|
71
68
|
{
|
|
72
69
|
nbr_tests: Integer(test_suite.tests || 0),
|
|
73
70
|
total_time: Float(test_suite.time),
|
|
@@ -79,7 +76,7 @@ module BlinkaReporter
|
|
|
79
76
|
def xml_seed(ox_properties)
|
|
80
77
|
ox_properties.each do |property|
|
|
81
78
|
property.nodes.each do |node|
|
|
82
|
-
return node.attributes[:value] if node.attributes[:name] ==
|
|
79
|
+
return node.attributes[:value] if node.attributes[:name] == "seed"
|
|
83
80
|
end
|
|
84
81
|
end
|
|
85
82
|
nil
|
|
@@ -89,18 +86,18 @@ module BlinkaReporter
|
|
|
89
86
|
def xml_test_cases(test_cases)
|
|
90
87
|
test_cases.map do |test_case|
|
|
91
88
|
result = {
|
|
92
|
-
kind: Array(test_case.attributes[:classname]&.split(
|
|
89
|
+
kind: Array(test_case.attributes[:classname]&.split("."))[1],
|
|
93
90
|
name: test_case.attributes[:name],
|
|
94
|
-
path: test_case.attributes[:file]&.delete_prefix(
|
|
91
|
+
path: test_case.attributes[:file]&.delete_prefix("./"),
|
|
95
92
|
time: Float(test_case.attributes[:time] || 0)
|
|
96
93
|
}
|
|
97
94
|
if test_case.nodes.any?
|
|
98
|
-
skipped = test_case.nodes.any? { |node| node.name ==
|
|
99
|
-
result[:result] =
|
|
95
|
+
skipped = test_case.nodes.any? { |node| node.name == "skipped" }
|
|
96
|
+
result[:result] = "skip" if skipped
|
|
100
97
|
failure =
|
|
101
|
-
test_case.nodes.
|
|
98
|
+
test_case.nodes.find { |node| node.name == "failure" }
|
|
102
99
|
if failure
|
|
103
|
-
result[:result] =
|
|
100
|
+
result[:result] = "fail"
|
|
104
101
|
|
|
105
102
|
# Needs to be double quotation marks to work properly
|
|
106
103
|
result[:backtrace] = failure.text.split("\n")
|
|
@@ -108,7 +105,7 @@ module BlinkaReporter
|
|
|
108
105
|
result[:message] = failure.attributes[:message]
|
|
109
106
|
end
|
|
110
107
|
else
|
|
111
|
-
result[:result] =
|
|
108
|
+
result[:result] = "pass"
|
|
112
109
|
end
|
|
113
110
|
result
|
|
114
111
|
end
|
|
@@ -116,7 +113,7 @@ module BlinkaReporter
|
|
|
116
113
|
|
|
117
114
|
def get_image_path(backtrace)
|
|
118
115
|
backtrace.each do |text|
|
|
119
|
-
path = /^(\[Screenshot\]|\[Screenshot Image\]):\s(
|
|
116
|
+
path = /^(\[Screenshot\]|\[Screenshot Image\]):\s(\S*)$/.match(text)
|
|
120
117
|
next if path.nil?
|
|
121
118
|
path = path[-1]
|
|
122
119
|
next unless File.exist?(path)
|
|
@@ -5,7 +5,7 @@ module BlinkaReporter
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def path
|
|
8
|
-
@path ||= source_location.first.gsub(Dir.getwd,
|
|
8
|
+
@path ||= source_location.first.gsub(Dir.getwd, "").delete_prefix("/")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def line
|
|
@@ -24,8 +24,8 @@ module BlinkaReporter
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def kind
|
|
27
|
-
parts =
|
|
28
|
-
parts.length > 1 ? parts.first :
|
|
27
|
+
parts = path.gsub("test/", "").split("/")
|
|
28
|
+
(parts.length > 1) ? parts.first : "general"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def message
|
|
@@ -60,14 +60,17 @@ module BlinkaReporter
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def image
|
|
63
|
-
return unless kind ==
|
|
63
|
+
return unless kind == "system"
|
|
64
64
|
|
|
65
65
|
image_path =
|
|
66
66
|
if defined?(Capybara) && Capybara.respond_to?(:save_path) &&
|
|
67
|
-
|
|
68
|
-
"#{Capybara.save_path}/failures_#{name}.png"
|
|
67
|
+
Capybara.save_path.present?
|
|
68
|
+
"#{Capybara.save_path}/failures_#{name}.png".gsub(
|
|
69
|
+
Dir.getwd,
|
|
70
|
+
""
|
|
71
|
+
).delete_prefix("/")
|
|
69
72
|
else
|
|
70
|
-
"
|
|
73
|
+
"tmp/screenshots/failures_#{name}.png"
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
return unless File.exist?(image_path)
|
data/lib/blinka_reporter/tap.rb
CHANGED
|
@@ -14,31 +14,31 @@ module BlinkaReporter
|
|
|
14
14
|
return if results.size == 0
|
|
15
15
|
|
|
16
16
|
@data = <<~REPORT
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
TAP version 13
|
|
18
|
+
1..#{results.size}
|
|
19
|
+
#{test_results(results)}
|
|
20
20
|
REPORT
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_results(results)
|
|
24
24
|
report = []
|
|
25
25
|
results.each_with_index do |test, index|
|
|
26
|
-
test_str = "#{test[:path]} - #{test[:name].tr(
|
|
26
|
+
test_str = "#{test[:path]} - #{test[:name].tr("#", "_")}"
|
|
27
27
|
result = test[:result]
|
|
28
|
-
if result ==
|
|
28
|
+
if result == "pass"
|
|
29
29
|
report << "ok #{index + 1} - #{test_str}"
|
|
30
|
-
elsif result ==
|
|
30
|
+
elsif result == "skip"
|
|
31
31
|
report << "ok #{index + 1} # skip: #{test_str}"
|
|
32
|
-
elsif result ==
|
|
32
|
+
elsif result == "fail"
|
|
33
33
|
report << "not ok #{index + 1} - failed: #{test_str}"
|
|
34
34
|
test[:message].split('\n') do |line|
|
|
35
|
-
report << "##{
|
|
35
|
+
report << "##{" " * TAP_COMMENT_PAD + line}"
|
|
36
36
|
end
|
|
37
|
-
report <<
|
|
37
|
+
report << "#"
|
|
38
38
|
Array(test[:backtrace]).each do |line|
|
|
39
|
-
report << "##{
|
|
39
|
+
report << "##{" " * TAP_COMMENT_PAD + line}"
|
|
40
40
|
end
|
|
41
|
-
report <<
|
|
41
|
+
report << ""
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
report.join("\n")
|
data/lib/blinka_reporter.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
1
|
+
require "minitest"
|
|
2
|
+
require "json"
|
|
3
|
+
require "blinka_reporter/minitest_adapter"
|
|
4
|
+
require "blinka_reporter/client"
|
|
5
5
|
|
|
6
6
|
module Minitest
|
|
7
7
|
def self.plugin_blinka_init(options)
|
|
8
|
-
reporter
|
|
8
|
+
reporter << BlinkaPlugin::Reporter.new(options[:io], options)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def plugin_blinka_options(opts, options)
|
|
11
|
+
def self.plugin_blinka_options(opts, options)
|
|
12
|
+
end
|
|
12
13
|
|
|
13
14
|
module BlinkaPlugin
|
|
14
15
|
class Reporter < Minitest::StatisticsReporter
|
|
@@ -31,8 +32,8 @@ module Minitest
|
|
|
31
32
|
private
|
|
32
33
|
|
|
33
34
|
def json_report
|
|
34
|
-
report_path = ENV[
|
|
35
|
-
return if report_path.nil? || report_path.eql?(
|
|
35
|
+
report_path = ENV["BLINKA_PATH"]
|
|
36
|
+
return if report_path.nil? || report_path.eql?("")
|
|
36
37
|
|
|
37
38
|
result = {
|
|
38
39
|
total_time: total_time,
|
|
@@ -45,19 +46,17 @@ module Minitest
|
|
|
45
46
|
end || []
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
if ENV[
|
|
49
|
+
if ENV["BLINKA_APPEND"] == "true" && File.exist?(report_path)
|
|
49
50
|
existing =
|
|
50
|
-
JSON.parse(File.
|
|
51
|
+
JSON.parse(File.read(report_path), symbolize_names: true)
|
|
51
52
|
result[:results] = existing[:results] + result[:results]
|
|
52
53
|
result[:nbr_tests] = existing[:nbr_tests] + result[:nbr_tests]
|
|
53
|
-
result[:nbr_assertions] =
|
|
54
|
-
|
|
54
|
+
result[:nbr_assertions] = existing[:nbr_assertions] +
|
|
55
|
+
result[:nbr_assertions]
|
|
55
56
|
result[:total_time] = existing[:total_time] + result[:total_time]
|
|
56
57
|
end
|
|
57
58
|
|
|
58
|
-
File.
|
|
59
|
-
file.write(JSON.pretty_generate(result))
|
|
60
|
-
end
|
|
59
|
+
File.write(report_path, JSON.pretty_generate(result))
|
|
61
60
|
|
|
62
61
|
puts
|
|
63
62
|
puts("Test results written to `#{report_path}`")
|
|
@@ -65,3 +64,15 @@ module Minitest
|
|
|
65
64
|
end
|
|
66
65
|
end
|
|
67
66
|
end
|
|
67
|
+
|
|
68
|
+
if Minitest.respond_to?(:extensions)
|
|
69
|
+
registered = Minitest.extensions.map(&:to_s).include?("blinka")
|
|
70
|
+
|
|
71
|
+
unless registered
|
|
72
|
+
if Minitest.respond_to?(:register_plugin)
|
|
73
|
+
Minitest.register_plugin(:blinka)
|
|
74
|
+
else
|
|
75
|
+
Minitest.extensions << "blinka"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/package.json
CHANGED
|
@@ -4,19 +4,21 @@
|
|
|
4
4
|
"author": "David Wessman <david@wessman.co>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"pretty": "./node_modules/.bin/prettier --write ."
|
|
7
|
+
"husky": "^9.1.7",
|
|
8
|
+
"lint-staged": "^16.2.7",
|
|
9
|
+
"prettier": "^3.8.0"
|
|
13
10
|
},
|
|
14
11
|
"husky": {
|
|
15
12
|
"hooks": {
|
|
16
13
|
"pre-commit": "lint-staged"
|
|
17
14
|
}
|
|
18
15
|
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"pretty": "./node_modules/.bin/prettier --write . && stree write './**/*.rb'",
|
|
18
|
+
"prepare": "husky install"
|
|
19
|
+
},
|
|
19
20
|
"lint-staged": {
|
|
20
|
-
"*.{
|
|
21
|
+
"*.{rb,gemspec}": "stree write",
|
|
22
|
+
"*.{js,css,md,json,yml}": "./node_modules/.bin/prettier --write"
|
|
21
23
|
}
|
|
22
24
|
}
|