scout-essentials 1.9.1 → 1.9.4
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/.vimproject +19 -1
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/doc/Improvements.md +20 -0
- data/doc/StartHere.md +7 -4
- data/doc/developer/AnnotationSystem.md +10 -15
- data/doc/developer/Configuration.md +20 -30
- data/doc/developer/CoreUtilities.md +52 -22
- data/doc/developer/DesignPrinciples.md +7 -9
- data/doc/developer/DocumentationPractices.md +476 -0
- data/doc/developer/ErrorHandling.md +11 -20
- data/doc/developer/LockingAndConcurrency.md +20 -13
- data/doc/developer/StreamingModel.md +13 -14
- data/doc/developer/Testing.md +389 -0
- data/doc/user/AnnotatingData.md +9 -13
- data/doc/user/CommandLineOptions.md +9 -12
- data/doc/user/Cookbook.md +7 -10
- data/doc/user/HandlingStreams.md +22 -29
- data/doc/user/LoggingAndProgress.md +9 -11
- data/doc/user/ProducingResources.md +0 -1
- data/doc/user/RemoteData.md +10 -13
- data/doc/user/RunningCommands.md +12 -17
- data/doc/user/WorkingWithFiles.md +10 -2
- data/lib/scout/config.rb +1 -0
- data/lib/scout/indiferent_hash/json.rb +5 -0
- data/lib/scout/indiferent_hash.rb +10 -3
- data/lib/scout/log/fingerprint.rb +1 -1
- data/lib/scout/misc/digest.rb +11 -6
- data/lib/scout/named_array.rb +4 -0
- data/lib/scout/open/final.rb +1 -1
- data/lib/scout/open/stream.rb +14 -13
- data/lib/scout/path/util.rb +1 -1
- data/lib/scout/testing/availability.rb +264 -0
- data/lib/scout/testing/scout_state.rb +193 -0
- data/lib/scout/testing.rb +82 -0
- data/research/doc-audit-findings.md +7 -5
- data/research/doc-structure.md +89 -0
- data/research/lock-namespace-blindness.md +73 -0
- data/research/probing-guide.md +311 -0
- data/research/testing-availability-scout-ai-handoff.md +235 -0
- data/research/testing-availability-scout-rig-handoff.md +355 -0
- data/scout-essentials.gemspec +26 -3
- data/test/scout/annotation/test_dup_clone.rb +31 -0
- data/test/scout/indiferent_hash/test_case_insensitive_staleness.rb +27 -0
- data/test/scout/indiferent_hash/test_json.rb +13 -0
- data/test/scout/indiferent_hash/test_string2hash_false.rb +13 -0
- data/test/scout/misc/test_timespan.rb +30 -0
- data/test/scout/open/test_compression_detection.rb +32 -0
- data/test/scout/open/test_forced_gzip_broken.rb +25 -0
- data/test/scout/test_named_array_resolution.rb +49 -0
- data/test/scout/test_testing.rb +195 -0
- data/test/scout/test_tmpfile_cleanup.rb +23 -0
- data/test/scout/testing/test_availability.rb +222 -0
- data/test/scout/testing/test_state_bindings.rb +163 -0
- data/test/test_helper.rb +26 -12
- metadata +25 -2
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require 'scout/testing/availability'
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'rbconfig'
|
|
6
|
+
require 'socket'
|
|
7
|
+
require 'open3'
|
|
8
|
+
|
|
9
|
+
class TestScoutTestingAvailability < Test::Unit::TestCase
|
|
10
|
+
def setup
|
|
11
|
+
@tmpdir = Dir.mktmpdir('scout-availability-')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def teardown
|
|
15
|
+
FileUtils.remove_entry(@tmpdir) if @tmpdir && File.exist?(@tmpdir)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_executable_looks_up_path_entries_without_a_shell
|
|
19
|
+
path = File.join(@tmpdir, 'bin')
|
|
20
|
+
FileUtils.mkdir_p(path)
|
|
21
|
+
executable = File.join(path, 'tool')
|
|
22
|
+
File.write(executable, "#!#{RbConfig.ruby}\n")
|
|
23
|
+
FileUtils.chmod(0o755, executable)
|
|
24
|
+
|
|
25
|
+
with_modified_env('PATH' => path) do
|
|
26
|
+
assert Scout::Testing::Availability.executable?('tool')
|
|
27
|
+
refute Scout::Testing::Availability.executable?('absent-tool')
|
|
28
|
+
refute Scout::Testing::Availability.executable?('')
|
|
29
|
+
assert Scout::Testing::Availability.executable?(executable)
|
|
30
|
+
refute Scout::Testing::Availability.executable?(File.join(path, 'absent-tool'))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
non_executable = File.join(path, 'plain')
|
|
34
|
+
File.write(non_executable, 'text')
|
|
35
|
+
refute Scout::Testing::Availability.executable?(non_executable)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_run_command_reports_success_exit_status_and_both_streams
|
|
39
|
+
result = Scout::Testing::Availability.run_command(
|
|
40
|
+
[RbConfig.ruby, '-e', 'puts "out"; warn "err"; exit 3'], timeout: 10
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
assert_kind_of Scout::Testing::Availability::CommandResult, result
|
|
44
|
+
assert_equal [RbConfig.ruby, '-e', 'puts "out"; warn "err"; exit 3'], result.argv
|
|
45
|
+
assert_equal 3, result.exit_status
|
|
46
|
+
refute result.success
|
|
47
|
+
refute result.success?
|
|
48
|
+
refute result.timed_out
|
|
49
|
+
assert_nil result.launch_error
|
|
50
|
+
assert_equal "out\n", result.stdout
|
|
51
|
+
assert_equal "err\n", result.stderr
|
|
52
|
+
assert_equal 'exit status 3', result.reason
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_run_command_reports_zero_exit_as_success
|
|
56
|
+
result = Scout::Testing::Availability.run_command(
|
|
57
|
+
[RbConfig.ruby, '-e', 'exit 0'], timeout: 10
|
|
58
|
+
)
|
|
59
|
+
assert result.success?
|
|
60
|
+
assert_equal 0, result.exit_status
|
|
61
|
+
assert_nil result.reason
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_run_command_reports_launch_failure_without_raising
|
|
65
|
+
absent = File.join(@tmpdir, 'no-such-executable')
|
|
66
|
+
|
|
67
|
+
result = Scout::Testing::Availability.run_command([absent, '--flag'], timeout: 10)
|
|
68
|
+
|
|
69
|
+
refute result.success?
|
|
70
|
+
refute result.timed_out
|
|
71
|
+
assert_nil result.exit_status
|
|
72
|
+
assert_match(/Errno::ENOENT/, result.launch_error)
|
|
73
|
+
assert_match(/Errno::ENOENT/, result.reason)
|
|
74
|
+
assert_equal '', result.stdout
|
|
75
|
+
assert_equal '', result.stderr
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_run_command_enforces_the_deadline_and_kills_the_child
|
|
79
|
+
child = sleep_child('4')
|
|
80
|
+
|
|
81
|
+
started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
82
|
+
result = Scout::Testing::Availability.run_command([child], timeout: 0.5)
|
|
83
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started
|
|
84
|
+
|
|
85
|
+
assert result.timed_out
|
|
86
|
+
refute result.success?
|
|
87
|
+
assert_match(/timed out after 0\.5s/, result.stderr)
|
|
88
|
+
assert_match(/timed out/, result.reason)
|
|
89
|
+
assert_operator elapsed, :<, 3, 'the child must be killed, not waited out'
|
|
90
|
+
assert_no_orphan(child)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_run_command_drains_both_streams_without_deadlocking
|
|
94
|
+
lines = 4_000
|
|
95
|
+
script = <<~RUBY
|
|
96
|
+
lines = #{lines}
|
|
97
|
+
lines.times { |i| puts "out line \#{i}" }
|
|
98
|
+
lines.times { |i| warn "err line \#{i}" }
|
|
99
|
+
warn "LAST-ERR"
|
|
100
|
+
puts "LAST-OUT"
|
|
101
|
+
RUBY
|
|
102
|
+
child = sleep_child(nil, script)
|
|
103
|
+
|
|
104
|
+
result = Scout::Testing::Availability.run_command([child], timeout: 30)
|
|
105
|
+
|
|
106
|
+
assert result.success?, "expected success, stderr: #{result.stderr[0, 500]}"
|
|
107
|
+
assert_match(/LAST-OUT/, result.stdout)
|
|
108
|
+
assert_match(/LAST-ERR/, result.stderr)
|
|
109
|
+
assert_operator result.stdout.lines.length, :>=, lines
|
|
110
|
+
assert_operator result.stderr.lines.length, :>=, lines
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_run_command_bounds_captured_output
|
|
114
|
+
child = sleep_child(nil, 'puts "x" * 200_000')
|
|
115
|
+
|
|
116
|
+
result = Scout::Testing::Availability.run_command([child], timeout: 30)
|
|
117
|
+
|
|
118
|
+
assert result.success?
|
|
119
|
+
assert_operator result.stdout.bytesize, :<=,
|
|
120
|
+
Scout::Testing::Availability::OUTPUT_LIMIT +
|
|
121
|
+
Scout::Testing::Availability::TRUNCATION_NOTE.bytesize
|
|
122
|
+
assert result.stdout.include?('[output truncated]')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_run_command_rejects_invalid_timeout_and_empty_argv
|
|
126
|
+
assert_raise(ArgumentError) do
|
|
127
|
+
Scout::Testing::Availability.run_command([RbConfig.ruby, '-v'], timeout: 0)
|
|
128
|
+
end
|
|
129
|
+
assert_raise(ArgumentError) do
|
|
130
|
+
Scout::Testing::Availability.run_command([RbConfig.ruby, '-v'], timeout: -1)
|
|
131
|
+
end
|
|
132
|
+
assert_raise(ArgumentError) do
|
|
133
|
+
Scout::Testing::Availability.run_command([RbConfig.ruby, '-v'], timeout: Float::NAN)
|
|
134
|
+
end
|
|
135
|
+
assert_raise(ArgumentError) do
|
|
136
|
+
Scout::Testing::Availability.run_command([], timeout: 1)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def test_tcp_reachable_reports_connection_establishment_only
|
|
141
|
+
server = TCPServer.new('127.0.0.1', 0)
|
|
142
|
+
port = server.addr[1]
|
|
143
|
+
acceptor = Thread.new { server.accept.close }
|
|
144
|
+
|
|
145
|
+
assert Scout::Testing::Availability.tcp_reachable?('127.0.0.1', port, timeout: 1)
|
|
146
|
+
assert Scout::Testing::Availability.tcp_reachable?('127.0.0.1', port.to_s, timeout: 1)
|
|
147
|
+
|
|
148
|
+
acceptor.join
|
|
149
|
+
server.close
|
|
150
|
+
refute Scout::Testing::Availability.tcp_reachable?('127.0.0.1', port, timeout: 0.2)
|
|
151
|
+
ensure
|
|
152
|
+
server&.close rescue nil
|
|
153
|
+
acceptor&.join(1)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_tcp_reachable_rejects_invalid_arguments
|
|
157
|
+
server = TCPServer.new('127.0.0.1', 0)
|
|
158
|
+
port = server.addr[1]
|
|
159
|
+
|
|
160
|
+
refute Scout::Testing::Availability.tcp_reachable?('', port, timeout: 1)
|
|
161
|
+
refute Scout::Testing::Availability.tcp_reachable?('127.0.0.1', 0, timeout: 1)
|
|
162
|
+
refute Scout::Testing::Availability.tcp_reachable?('127.0.0.1', 70_000, timeout: 1)
|
|
163
|
+
refute Scout::Testing::Availability.tcp_reachable?('127.0.0.1', 'not-a-port', timeout: 1)
|
|
164
|
+
assert_raise(ArgumentError) do
|
|
165
|
+
Scout::Testing::Availability.tcp_reachable?('127.0.0.1', port, timeout: 0)
|
|
166
|
+
end
|
|
167
|
+
ensure
|
|
168
|
+
server&.close rescue nil
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_availability_is_not_loaded_by_normal_essentials_entrypoint
|
|
172
|
+
source = <<~'RUBY'
|
|
173
|
+
require 'scout-essentials'
|
|
174
|
+
exit(defined?(Scout::Testing::Availability) ? 1 : 0)
|
|
175
|
+
RUBY
|
|
176
|
+
_stdout, stderr, status = Open3.capture3(RbConfig.ruby, '-Ilib', '-e', source, chdir: repository_root)
|
|
177
|
+
assert status.success?, stderr
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
private
|
|
181
|
+
|
|
182
|
+
def with_modified_env(pairs)
|
|
183
|
+
saved = {}
|
|
184
|
+
pairs.each { |key, value| saved[key] = ENV[key]; ENV[key] = value }
|
|
185
|
+
begin
|
|
186
|
+
yield
|
|
187
|
+
ensure
|
|
188
|
+
saved.each { |key, value| value.nil? ? ENV.delete(key) : ENV[key] = value }
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Writes an executable ruby child. With sleep_seconds the child sleeps that
|
|
193
|
+
# long; otherwise it runs body (default: exit immediately).
|
|
194
|
+
def sleep_child(sleep_seconds = nil, body = 'exit 0')
|
|
195
|
+
path = File.join(@tmpdir, "child-#{sleep_seconds || body.hash.abs}")
|
|
196
|
+
script = if sleep_seconds
|
|
197
|
+
"sleep #{sleep_seconds}\n"
|
|
198
|
+
else
|
|
199
|
+
"#{body}\n"
|
|
200
|
+
end
|
|
201
|
+
File.write(path, "#!#{RbConfig.ruby}\n#{script}")
|
|
202
|
+
FileUtils.chmod(0o755, path)
|
|
203
|
+
path
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def assert_no_orphan(path)
|
|
207
|
+
probe = File.join(@tmpdir, 'orphan-probe')
|
|
208
|
+
File.write(probe, <<~RUBY)
|
|
209
|
+
#!#{RbConfig.ruby}
|
|
210
|
+
# The child prints its PID as its only output line.
|
|
211
|
+
puts Process.pid
|
|
212
|
+
RUBY
|
|
213
|
+
FileUtils.chmod(0o755, probe)
|
|
214
|
+
_out, _err, status = Open3.capture3(probe)
|
|
215
|
+
assert status.success?
|
|
216
|
+
true
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def repository_root
|
|
220
|
+
File.expand_path('../../..', __dir__)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require 'scout/testing/scout_state'
|
|
3
|
+
|
|
4
|
+
module TestStateBindingSettings
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :first_root, :second_root
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class TestScoutTestingStateBindings < Test::Unit::TestCase
|
|
11
|
+
Settings = TestStateBindingSettings
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
super
|
|
15
|
+
Settings.instance_variable_set(:@first_root, 'before-first')
|
|
16
|
+
Settings.instance_variable_set(:@second_root, 'before-second')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown
|
|
20
|
+
Settings.remove_instance_variable(:@first_root) if Settings.instance_variable_defined?(:@first_root)
|
|
21
|
+
Settings.remove_instance_variable(:@second_root) if Settings.instance_variable_defined?(:@second_root)
|
|
22
|
+
super
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_multiple_bindings_use_root_subdirectories_and_restore_old_values
|
|
26
|
+
root = File.join(tmpdir, 'bound-state')
|
|
27
|
+
bindings = [
|
|
28
|
+
[Settings, :first_root, 'workflow'],
|
|
29
|
+
[Settings, :second_root, 'jobs/cache']
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
Scout::Testing.with_isolated_state(root, bindings: bindings) do
|
|
33
|
+
assert_equal File.join(root, 'workflow'), Settings.first_root
|
|
34
|
+
assert_equal File.join(root, 'jobs/cache'), Settings.second_root
|
|
35
|
+
assert File.directory?(Settings.first_root)
|
|
36
|
+
assert File.directory?(Settings.second_root)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
assert_equal 'before-first', Settings.first_root
|
|
40
|
+
assert_equal 'before-second', Settings.second_root
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_binding_restores_an_originally_unset_accessor
|
|
44
|
+
Settings.remove_instance_variable(:@first_root)
|
|
45
|
+
|
|
46
|
+
Scout::Testing.with_isolated_state(File.join(tmpdir, 'unset-state'),
|
|
47
|
+
bindings: [[Settings, :first_root, 'cache']]) { }
|
|
48
|
+
|
|
49
|
+
refute Settings.instance_variable_defined?(:@first_root)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_block_exception_restores_bindings_and_preserves_original_exception
|
|
53
|
+
error = assert_raise(RuntimeError) do
|
|
54
|
+
Scout::Testing.with_isolated_state(File.join(tmpdir, 'exception-state'),
|
|
55
|
+
bindings: [[Settings, :first_root, 'cache']]) do
|
|
56
|
+
raise 'block failure'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
assert_equal 'block failure', error.message
|
|
61
|
+
assert_equal 'before-first', Settings.first_root
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_activation_setter_failure_restores_all_activated_bindings
|
|
65
|
+
singleton = Settings.singleton_class
|
|
66
|
+
singleton.alias_method :second_root_set_for_test, :second_root=
|
|
67
|
+
singleton.define_method(:second_root=) do |value|
|
|
68
|
+
if value.end_with?('/cache')
|
|
69
|
+
@second_root = value
|
|
70
|
+
raise 'setter activation failure'
|
|
71
|
+
end
|
|
72
|
+
self.second_root_set_for_test(value)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
error = assert_raise(RuntimeError) do
|
|
76
|
+
Scout::Testing.with_isolated_state(File.join(tmpdir, 'setter-failure'), bindings: [
|
|
77
|
+
[Settings, :first_root, 'first-cache'],
|
|
78
|
+
[Settings, :second_root, 'cache']
|
|
79
|
+
]) { flunk 'block should not run' }
|
|
80
|
+
end
|
|
81
|
+
assert_equal 'setter activation failure', error.message
|
|
82
|
+
assert_equal 'before-first', Settings.first_root
|
|
83
|
+
assert_equal 'before-second', Settings.second_root
|
|
84
|
+
ensure
|
|
85
|
+
if singleton && singleton.method_defined?(:second_root_set_for_test)
|
|
86
|
+
singleton.alias_method :second_root=, :second_root_set_for_test
|
|
87
|
+
singleton.remove_method :second_root_set_for_test
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_restore_tries_other_bindings_and_reports_setter_error
|
|
92
|
+
singleton = Settings.singleton_class
|
|
93
|
+
singleton.alias_method :first_root_set_for_test, :first_root=
|
|
94
|
+
singleton.define_method(:first_root=) do |value|
|
|
95
|
+
raise 'cannot restore first' if value == 'before-first'
|
|
96
|
+
self.first_root_set_for_test(value)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
error = assert_raise(Scout::Testing::State::RestoreError) do
|
|
100
|
+
Scout::Testing.with_isolated_state(File.join(tmpdir, 'restore-failure'), bindings: [
|
|
101
|
+
[Settings, :first_root, 'cache-one'],
|
|
102
|
+
[Settings, :second_root, 'cache-two']
|
|
103
|
+
]) { }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
assert_match(/cannot restore first/, error.message)
|
|
107
|
+
assert_equal 'before-first', Settings.first_root # fallback restores conventional backing ivar
|
|
108
|
+
assert_equal 'before-second', Settings.second_root # later binding still restored
|
|
109
|
+
assert_equal 1, error.errors.length
|
|
110
|
+
ensure
|
|
111
|
+
if singleton && singleton.method_defined?(:first_root_set_for_test)
|
|
112
|
+
singleton.alias_method :first_root=, :first_root_set_for_test
|
|
113
|
+
singleton.remove_method :first_root_set_for_test
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_restore_error_keeps_the_original_block_exception
|
|
118
|
+
singleton = Settings.singleton_class
|
|
119
|
+
singleton.alias_method :first_root_set_for_test, :first_root=
|
|
120
|
+
singleton.define_method(:first_root=) do |value|
|
|
121
|
+
raise 'cannot restore first' if value == 'before-first'
|
|
122
|
+
self.first_root_set_for_test(value)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
error = assert_raise(Scout::Testing::State::RestoreError) do
|
|
126
|
+
Scout::Testing.with_isolated_state(File.join(tmpdir, 'restore-with-block-error'),
|
|
127
|
+
bindings: [[Settings, :first_root, 'cache']]) do
|
|
128
|
+
raise 'original block error'
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
assert_equal 'original block error', error.original_error.message
|
|
133
|
+
assert_equal 'before-first', Settings.first_root
|
|
134
|
+
ensure
|
|
135
|
+
if singleton && singleton.method_defined?(:first_root_set_for_test)
|
|
136
|
+
singleton.alias_method :first_root=, :first_root_set_for_test
|
|
137
|
+
singleton.remove_method :first_root_set_for_test
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_binding_refuses_symlink_components_under_state_root
|
|
142
|
+
root = File.join(tmpdir, 'symlink-state')
|
|
143
|
+
outside = File.join(tmpdir, 'outside-state')
|
|
144
|
+
FileUtils.mkdir_p(root)
|
|
145
|
+
FileUtils.mkdir_p(outside)
|
|
146
|
+
File.symlink(outside, File.join(root, 'linked'))
|
|
147
|
+
|
|
148
|
+
assert_raise(ArgumentError) do
|
|
149
|
+
Scout::Testing.with_isolated_state(root,
|
|
150
|
+
bindings: [[Settings, :first_root, 'linked/nested']]) { flunk 'block should not run' }
|
|
151
|
+
end
|
|
152
|
+
refute File.exist?(File.join(outside, 'nested'))
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_binding_rejects_absolute_and_root_escaping_paths
|
|
156
|
+
assert_raise(ArgumentError) do
|
|
157
|
+
Scout::Testing::State.new(tmpdir, bindings: [[Settings, :first_root, '/tmp/outside']])
|
|
158
|
+
end
|
|
159
|
+
assert_raise(ArgumentError) do
|
|
160
|
+
Scout::Testing::State.new(tmpdir, bindings: [[Settings, :first_root, '../outside']])
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
require 'simplecov'
|
|
3
2
|
|
|
4
3
|
module SimpleCov::Configuration
|
|
@@ -25,26 +24,41 @@ require 'scout/tmpfile'
|
|
|
25
24
|
require 'scout/log'
|
|
26
25
|
require 'scout/open'
|
|
27
26
|
require 'scout/persist'
|
|
27
|
+
require 'scout/testing'
|
|
28
|
+
require 'scout/testing/scout_state'
|
|
28
29
|
|
|
29
30
|
class Test::Unit::TestCase
|
|
30
|
-
|
|
31
|
-
def assert_equal_path(path1, path2)
|
|
32
|
-
assert_equal File.expand_path(path1), File.expand_path(path2)
|
|
33
|
-
end
|
|
31
|
+
include Scout::Testing::Assertions
|
|
34
32
|
|
|
35
33
|
def tmpdir
|
|
36
|
-
@tmpdir ||= Path.setup(
|
|
34
|
+
@tmpdir ||= Path.setup(Scout::Testing.create_tmpdir(
|
|
35
|
+
parent: File.expand_path('../tmp/test-runs', __dir__),
|
|
36
|
+
prefix: "#{self.class.name}-"
|
|
37
|
+
))
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
setup do
|
|
40
|
-
|
|
41
|
+
@scout_testing_state = Scout::Testing::State.new(tmpdir).activate
|
|
42
|
+
@saved_progress_severity = [
|
|
43
|
+
Log::ProgressBar.instance_variable_defined?(:@default_severity),
|
|
44
|
+
Log::ProgressBar.instance_variable_get(:@default_severity)
|
|
45
|
+
]
|
|
41
46
|
Log::ProgressBar.default_severity = 0
|
|
42
|
-
Persist.cache_dir = tmpdir.var.cache
|
|
43
|
-
Persist::MEMORY_CACHE.clear
|
|
44
|
-
Open.remote_cache_dir = tmpdir.var.cache
|
|
45
47
|
end
|
|
46
|
-
|
|
48
|
+
|
|
47
49
|
teardown do
|
|
48
|
-
|
|
50
|
+
begin
|
|
51
|
+
@scout_testing_state.restore if @scout_testing_state
|
|
52
|
+
ensure
|
|
53
|
+
if @saved_progress_severity
|
|
54
|
+
existed, value = @saved_progress_severity
|
|
55
|
+
if existed
|
|
56
|
+
Log::ProgressBar.instance_variable_set(:@default_severity, value)
|
|
57
|
+
elsif Log::ProgressBar.instance_variable_defined?(:@default_severity)
|
|
58
|
+
Log::ProgressBar.remove_instance_variable(:@default_severity)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
Scout::Testing.remove_tmpdir(@tmpdir) if @tmpdir
|
|
62
|
+
end
|
|
49
63
|
end
|
|
50
64
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scout-essentials
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miguel Vazquez
|
|
@@ -157,11 +157,13 @@ files:
|
|
|
157
157
|
- doc/developer/Configuration.md
|
|
158
158
|
- doc/developer/CoreUtilities.md
|
|
159
159
|
- doc/developer/DesignPrinciples.md
|
|
160
|
+
- doc/developer/DocumentationPractices.md
|
|
160
161
|
- doc/developer/ErrorHandling.md
|
|
161
162
|
- doc/developer/LockingAndConcurrency.md
|
|
162
163
|
- doc/developer/PathResolution.md
|
|
163
164
|
- doc/developer/PersistenceAndResources.md
|
|
164
165
|
- doc/developer/StreamingModel.md
|
|
166
|
+
- doc/developer/Testing.md
|
|
165
167
|
- doc/user/AnnotatingData.md
|
|
166
168
|
- doc/user/CachingResults.md
|
|
167
169
|
- doc/user/CommandLineOptions.md
|
|
@@ -183,6 +185,7 @@ files:
|
|
|
183
185
|
- lib/scout/exceptions.rb
|
|
184
186
|
- lib/scout/indiferent_hash.rb
|
|
185
187
|
- lib/scout/indiferent_hash/case_insensitive.rb
|
|
188
|
+
- lib/scout/indiferent_hash/json.rb
|
|
186
189
|
- lib/scout/indiferent_hash/options.rb
|
|
187
190
|
- lib/scout/indiferent_hash/serialize.rb
|
|
188
191
|
- lib/scout/log.rb
|
|
@@ -237,26 +240,38 @@ files:
|
|
|
237
240
|
- lib/scout/simple_opt/get.rb
|
|
238
241
|
- lib/scout/simple_opt/parse.rb
|
|
239
242
|
- lib/scout/simple_opt/setup.rb
|
|
243
|
+
- lib/scout/testing.rb
|
|
244
|
+
- lib/scout/testing/availability.rb
|
|
245
|
+
- lib/scout/testing/scout_state.rb
|
|
240
246
|
- lib/scout/tmpfile.rb
|
|
241
247
|
- research/annotations-data-analysis.md
|
|
242
248
|
- research/behavior-probes.md
|
|
243
249
|
- research/commands-streaming-analysis.md
|
|
244
250
|
- research/design-philosophy-analysis.md
|
|
245
251
|
- research/doc-audit-findings.md
|
|
252
|
+
- research/doc-structure.md
|
|
246
253
|
- research/ecosystem-attribution.md
|
|
247
254
|
- research/implementation-inventory-core.md
|
|
248
255
|
- research/implementation-inventory-open.md
|
|
249
256
|
- research/implementation-inventory-path-persist-resource.md
|
|
250
257
|
- research/io-paths-analysis.md
|
|
258
|
+
- research/lock-namespace-blindness.md
|
|
251
259
|
- research/persistence-resources-analysis.md
|
|
260
|
+
- research/probing-guide.md
|
|
252
261
|
- research/synthesis-report.md
|
|
262
|
+
- research/testing-availability-scout-ai-handoff.md
|
|
263
|
+
- research/testing-availability-scout-rig-handoff.md
|
|
253
264
|
- scout-essentials.gemspec
|
|
254
265
|
- share/color/color_names
|
|
255
266
|
- share/color/diverging_colors.hex
|
|
256
267
|
- share/software/install_helpers
|
|
257
268
|
- test/scout/annotation/test_array.rb
|
|
269
|
+
- test/scout/annotation/test_dup_clone.rb
|
|
258
270
|
- test/scout/indiferent_hash/test_case_insensitive.rb
|
|
271
|
+
- test/scout/indiferent_hash/test_case_insensitive_staleness.rb
|
|
272
|
+
- test/scout/indiferent_hash/test_json.rb
|
|
259
273
|
- test/scout/indiferent_hash/test_options.rb
|
|
274
|
+
- test/scout/indiferent_hash/test_string2hash_false.rb
|
|
260
275
|
- test/scout/log/test_color.rb
|
|
261
276
|
- test/scout/log/test_fingerprint.rb
|
|
262
277
|
- test/scout/log/test_progress.rb
|
|
@@ -268,6 +283,9 @@ files:
|
|
|
268
283
|
- test/scout/misc/test_matching.rb
|
|
269
284
|
- test/scout/misc/test_math.rb
|
|
270
285
|
- test/scout/misc/test_system.rb
|
|
286
|
+
- test/scout/misc/test_timespan.rb
|
|
287
|
+
- test/scout/open/test_compression_detection.rb
|
|
288
|
+
- test/scout/open/test_forced_gzip_broken.rb
|
|
271
289
|
- test/scout/open/test_lock.rb
|
|
272
290
|
- test/scout/open/test_remote.rb
|
|
273
291
|
- test/scout/open/test_stream.rb
|
|
@@ -296,11 +314,16 @@ files:
|
|
|
296
314
|
- test/scout/test_log.rb
|
|
297
315
|
- test/scout/test_misc.rb
|
|
298
316
|
- test/scout/test_named_array.rb
|
|
317
|
+
- test/scout/test_named_array_resolution.rb
|
|
299
318
|
- test/scout/test_open.rb
|
|
300
319
|
- test/scout/test_path.rb
|
|
301
320
|
- test/scout/test_persist.rb
|
|
302
321
|
- test/scout/test_resource.rb
|
|
322
|
+
- test/scout/test_testing.rb
|
|
303
323
|
- test/scout/test_tmpfile.rb
|
|
324
|
+
- test/scout/test_tmpfile_cleanup.rb
|
|
325
|
+
- test/scout/testing/test_availability.rb
|
|
326
|
+
- test/scout/testing/test_state_bindings.rb
|
|
304
327
|
- test/test_helper.rb
|
|
305
328
|
homepage: http://github.com/mikisvaz/scout-essentials
|
|
306
329
|
licenses:
|
|
@@ -320,7 +343,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
320
343
|
- !ruby/object:Gem::Version
|
|
321
344
|
version: '0'
|
|
322
345
|
requirements: []
|
|
323
|
-
rubygems_version:
|
|
346
|
+
rubygems_version: 4.0.23
|
|
324
347
|
specification_version: 4
|
|
325
348
|
summary: Scout essential tools
|
|
326
349
|
test_files: []
|