testerobly 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 +7 -0
- data/LICENSE +21 -0
- data/bin/testerobly +6 -0
- data/lib/testerobly/configuration.rb +12 -0
- data/lib/testerobly.rb +115 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 18fcbc0c6020f6948a601108fe53f03c2109c38dfaa6586fc529fcfca6dd6a84
|
|
4
|
+
data.tar.gz: 3c9e5af2cf0e5a41b8705672c494a086f950866f82beee2d712b028561c6e060
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7ab5a8842e6ded4194f697dad6e4cf6b2bebb224f8fb7e12c940d046b88b1ae91c388f012316709c698a9b95c76648ce353b781b3533e01a8eac7ce847404ff4
|
|
7
|
+
data.tar.gz: 9f427e05ad8e8b68e8fd214db1378638deda7ef67481479ebf1ebe0fe923fafec3ca2a344ea067e25afbe6c20480d9fbd9eb938256f17e3cd2acad88eaba569c
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Robert Starsi
|
|
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.
|
data/bin/testerobly
ADDED
data/lib/testerobly.rb
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "listen"
|
|
4
|
+
require "testerobly/configuration"
|
|
5
|
+
|
|
6
|
+
module Testerobly
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :configuration
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.configuration
|
|
12
|
+
@configuration ||= Configuration.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.configure
|
|
16
|
+
yield(configuration)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.load_external_config
|
|
20
|
+
config_file = File.expand_path("config/testerobly.rb", Dir.pwd)
|
|
21
|
+
load config_file if File.exist?(config_file)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Main
|
|
25
|
+
PAUSE_SECONDS = 5
|
|
26
|
+
PROCESSING_INTERVAL_SECONDS = 0.5
|
|
27
|
+
|
|
28
|
+
def initialize
|
|
29
|
+
@queue = Thread::Queue.new
|
|
30
|
+
@pause_until = Time.now
|
|
31
|
+
|
|
32
|
+
file_listener = Listen.to(Dir.getwd, relative: true, ignore!: %r{git/HEAD}) do |modified, added|
|
|
33
|
+
process_changes modified, added
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
file_listener.start
|
|
37
|
+
capture_input_thread = capture_input
|
|
38
|
+
|
|
39
|
+
loop do
|
|
40
|
+
sleep PROCESSING_INTERVAL_SECONDS
|
|
41
|
+
|
|
42
|
+
if item = @queue.shift
|
|
43
|
+
capture_input_thread.kill
|
|
44
|
+
log item[:message]
|
|
45
|
+
system item[:command]
|
|
46
|
+
capture_input_thread = capture_input
|
|
47
|
+
end
|
|
48
|
+
rescue Interrupt
|
|
49
|
+
capture_input_thread.kill
|
|
50
|
+
file_listener.stop
|
|
51
|
+
break
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def process_changes(modified, added)
|
|
56
|
+
changes = modified + added
|
|
57
|
+
return if changes.empty?
|
|
58
|
+
|
|
59
|
+
if changes.include?(".git/HEAD") || changes.include?(".git/logs/HEAD") || changes.include?(".git/index")
|
|
60
|
+
log "git operation detected, pausing for #{PAUSE_SECONDS}s"
|
|
61
|
+
@pause_until = Time.now + PAUSE_SECONDS
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
return if @pause_until > Time.now
|
|
65
|
+
|
|
66
|
+
tests = []
|
|
67
|
+
|
|
68
|
+
changes.each do |path|
|
|
69
|
+
case path
|
|
70
|
+
when /^lib\/.*\.rb$/
|
|
71
|
+
result = path.gsub %r{^lib/(.+)\.rb$}, 'test/\1_test.rb'
|
|
72
|
+
tests << result if File.exist?(result)
|
|
73
|
+
when /^app\/(channels|controllers|helpers|jobs|models)\/.*\.rb$/
|
|
74
|
+
result = path.gsub %r{^app/(.+)\.rb$}, 'test/\1_test.rb'
|
|
75
|
+
tests << result if File.exist?(result)
|
|
76
|
+
when /^test\/.*_test\.rb$/
|
|
77
|
+
tests << path
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if configuration.on_change.kind_of?(Proc)
|
|
81
|
+
configuration.on_change.call path, tests
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
tests.uniq!
|
|
86
|
+
|
|
87
|
+
if tests.any?
|
|
88
|
+
command = sprintf configuration.test_command, tests.join(" ")
|
|
89
|
+
message = "#{changes.join ", "} => #{tests.join ", "}"
|
|
90
|
+
@queue << Hash[command:, message:]
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def log(text)
|
|
95
|
+
puts "\e[2m#{text}\e[0m"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def capture_input
|
|
99
|
+
log "[Enter] #{configuration.test_all_command}"
|
|
100
|
+
|
|
101
|
+
Thread.new do
|
|
102
|
+
loop do
|
|
103
|
+
if [ "\r", "\n" ].include?($stdin.getc)
|
|
104
|
+
@queue << { command: configuration.test_all_command, message: configuration.test_all_command }
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def configuration
|
|
111
|
+
Testerobly::configuration
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: testerobly
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Robert Starsi
|
|
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: listen
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 3.9.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 3.9.0
|
|
26
|
+
description: Small test runner to launch alongside your developer session for immediate
|
|
27
|
+
feedback.
|
|
28
|
+
email: klevo@klevo.sk
|
|
29
|
+
executables:
|
|
30
|
+
- testerobly
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- LICENSE
|
|
35
|
+
- bin/testerobly
|
|
36
|
+
- lib/testerobly.rb
|
|
37
|
+
- lib/testerobly/configuration.rb
|
|
38
|
+
homepage: https://github.com/klevo/testerobly
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata: {}
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubygems_version: 3.7.1
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: run MiniTest when files change
|
|
59
|
+
test_files: []
|