omoteura-minitest 0.2.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 +7 -0
- data/LICENSE +21 -0
- data/lib/omoteura/minitest/reporter.rb +68 -0
- data/lib/omoteura/minitest.rb +27 -0
- metadata +77 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d05444dcec00ad373f2aab0b23bc7e20b655ff4b7eb72669e378e451bbc1c262
|
|
4
|
+
data.tar.gz: 5577d2a91e3edd9c4989faa88045d4a082baf174c2938218ca7c0f3d2f3ec896
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 55cddb1f6e95c780689bf672fa06ce7c1154a95759331ad9bcb13bd5624db08fe6cc6b60176b430dca3bed88f85ac57789150dc2b3bfe74fabadfc7c068ba368
|
|
7
|
+
data.tar.gz: 7683247c08f4385b8411518e872ec04aec186aeee14e72cfdb848e739b944bd04338e6eb8852807ba146b99d889b5e2e75df768519c9fee7aa483b900c8c3f4f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KAIBYAKU K.K
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "minitest"
|
|
5
|
+
require "omoteura/results_file"
|
|
6
|
+
|
|
7
|
+
module Omoteura
|
|
8
|
+
module Minitest
|
|
9
|
+
# Writes every test's result to the results file, located by the line
|
|
10
|
+
# the test starts on: the test "…" call, or def test_…. With parallel
|
|
11
|
+
# tests, Minitest hands the workers' results to this reporter in the
|
|
12
|
+
# main process, which writes the file once at the end.
|
|
13
|
+
class Reporter < ::Minitest::AbstractReporter
|
|
14
|
+
def initialize(path)
|
|
15
|
+
super()
|
|
16
|
+
@path = path
|
|
17
|
+
@examples = []
|
|
18
|
+
@lock = Mutex.new
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def record(result)
|
|
22
|
+
file, line = result.source_location
|
|
23
|
+
return unless file && line&.positive?
|
|
24
|
+
|
|
25
|
+
example = {
|
|
26
|
+
id: "#{result.klass}##{result.name}",
|
|
27
|
+
file_path: relative(file),
|
|
28
|
+
line_number: line,
|
|
29
|
+
full_description: "#{result.klass} #{description(result.name)}",
|
|
30
|
+
status: status(result),
|
|
31
|
+
message: message(result)
|
|
32
|
+
}
|
|
33
|
+
@lock.synchronize { @examples << example }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def report
|
|
37
|
+
FileUtils.mkdir_p(File.dirname(@path))
|
|
38
|
+
File.write(@path, ResultsFile.generate(@examples))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def relative(file)
|
|
44
|
+
path = File.expand_path(file)
|
|
45
|
+
root = File.join(Dir.pwd, "")
|
|
46
|
+
path.start_with?(root) ? path.delete_prefix(root) : path
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# test_requires_an_email, as ActiveSupport names test "requires an
|
|
50
|
+
# email", reads as the description it came from.
|
|
51
|
+
def description(name)
|
|
52
|
+
name.delete_prefix("test_").tr("_", " ")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def status(result)
|
|
56
|
+
if result.skipped? then "pending"
|
|
57
|
+
elsif result.passed? then "passed"
|
|
58
|
+
else "failed"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def message(result)
|
|
63
|
+
failure = result.failures.first
|
|
64
|
+
failure && ResultsFile.plain(failure.message)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "minitest"
|
|
4
|
+
require "omoteura/minitest/reporter"
|
|
5
|
+
|
|
6
|
+
module Omoteura
|
|
7
|
+
# Records Minitest results for the editor. Require it from
|
|
8
|
+
# test/test_helper.rb:
|
|
9
|
+
#
|
|
10
|
+
# require "omoteura/minitest"
|
|
11
|
+
#
|
|
12
|
+
# Each run then writes tmp/omoteura/results.json, or the path in the
|
|
13
|
+
# OMOTEURA_RESULTS environment variable, as Omoteura::RSpec::Formatter
|
|
14
|
+
# does for RSpec. Nothing is written unless this file is required.
|
|
15
|
+
module Minitest
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module Minitest
|
|
20
|
+
# Called by Minitest.init_plugins for each name in Minitest.extensions.
|
|
21
|
+
def self.plugin_omoteura_init(_options)
|
|
22
|
+
reporter << Omoteura::Minitest::Reporter.new(ENV.fetch("OMOTEURA_RESULTS", Omoteura::ResultsFile::DEFAULT_PATH))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Minitest.register_plugin does this from 5.22 on; this works from 5.21.
|
|
27
|
+
Minitest.extensions << "omoteura" unless Minitest.extensions.include?("omoteura")
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: omoteura-minitest
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- KAIBYAKU K.K
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: omoteura-core
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - '='
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.2.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - '='
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.2.0
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: minitest
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.21'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '7'
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '5.21'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '7'
|
|
46
|
+
executables: []
|
|
47
|
+
extensions: []
|
|
48
|
+
extra_rdoc_files: []
|
|
49
|
+
files:
|
|
50
|
+
- LICENSE
|
|
51
|
+
- lib/omoteura/minitest.rb
|
|
52
|
+
- lib/omoteura/minitest/reporter.rb
|
|
53
|
+
homepage: https://github.com/kaibyaku-jp/omoteura
|
|
54
|
+
licenses:
|
|
55
|
+
- MIT
|
|
56
|
+
metadata:
|
|
57
|
+
source_code_uri: https://github.com/kaibyaku-jp/omoteura
|
|
58
|
+
changelog_uri: https://github.com/kaibyaku-jp/omoteura/blob/main/CHANGELOG.md
|
|
59
|
+
rubygems_mfa_required: 'true'
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.4'
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubygems_version: 3.6.9
|
|
75
|
+
specification_version: 4
|
|
76
|
+
summary: Minitest result reporter for Omoteura
|
|
77
|
+
test_files: []
|