test-cmd.rb 2.6.0 → 2.7.1
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/README.md +2 -2
- data/lib/test/command/version.rb +1 -1
- data/lib/test/command.rb +5 -3
- data/test/cmd_test.rb +48 -9
- data/test-cmd.rb.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79bec627803ce82d85c99a7f55f00b007cdfba9ecf54634b8c48e9fa64083b17
|
|
4
|
+
data.tar.gz: 73ab470f82fc83f120ab84c5a4345ce6da2c417edf121e24db314ba2cd9b1dad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9d84416530c7becb5915bca84d2bc7eb17532d0bbb53756d205ab2ba06c6f63999ad395ca206e6a943d6f24fc2ce3913b0db7061164bab018499021a3705e20
|
|
7
|
+
data.tar.gz: 6aedc2200539e08f31eebd9d480cbb3c7a4ee0096e477d153a969096df542e79e5b3ac236ebabce6c476bba9f3fce2c3b5210c97e5378d9dd50a3e6fbc406d9c
|
data/README.md
CHANGED
|
@@ -41,7 +41,7 @@ require "test-cmd"
|
|
|
41
41
|
# Call the 'ls' command
|
|
42
42
|
p Test::Command
|
|
43
43
|
.new("ls")
|
|
44
|
-
.
|
|
44
|
+
.arguments("-l")
|
|
45
45
|
.stdout
|
|
46
46
|
|
|
47
47
|
##
|
|
@@ -65,8 +65,8 @@ p Test::Command
|
|
|
65
65
|
# stderr. At most 20k bytes is read from both:
|
|
66
66
|
p Test::Command
|
|
67
67
|
.new("git")
|
|
68
|
+
.arguments("diff", "--cached")
|
|
68
69
|
.limit(stdout: 20_000, stderr: 20_000)
|
|
69
|
-
.argv("diff", "--cached")
|
|
70
70
|
.stdout
|
|
71
71
|
```
|
|
72
72
|
|
data/lib/test/command/version.rb
CHANGED
data/lib/test/command.rb
CHANGED
|
@@ -38,12 +38,13 @@ class Test::Command
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
##
|
|
41
|
-
# @param [Array<String, #to_s>]
|
|
41
|
+
# @param [Array<String, #to_s>] arguments
|
|
42
42
|
# Command-line arguments
|
|
43
43
|
# @return [Test::Command]
|
|
44
|
-
def
|
|
45
|
-
tap { @argv.concat(
|
|
44
|
+
def arguments(*arguments)
|
|
45
|
+
tap { @argv.concat(arguments) }
|
|
46
46
|
end
|
|
47
|
+
alias_method :argv, :arguments
|
|
47
48
|
|
|
48
49
|
##
|
|
49
50
|
# @param [Hash{String => String}] env
|
|
@@ -116,6 +117,7 @@ class Test::Command
|
|
|
116
117
|
# writer thread does not block forever.
|
|
117
118
|
@in_r.close unless @in_r.equal?(IO::NULL)
|
|
118
119
|
@status = Process.waitpid2(Process.spawn("false")).last
|
|
120
|
+
self
|
|
119
121
|
end
|
|
120
122
|
|
|
121
123
|
##
|
data/test/cmd_test.rb
CHANGED
|
@@ -7,24 +7,41 @@ class Test::Command
|
|
|
7
7
|
def ruby(str)
|
|
8
8
|
::Test::Command.new "ruby", "-e", str
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# macos-specific env vars that are always set
|
|
13
|
+
# @return [String]
|
|
14
|
+
def macos
|
|
15
|
+
if ENV["__CF_USER_TEXT_ENCODING"]
|
|
16
|
+
"__CF_USER_TEXT_ENCODING\n"
|
|
17
|
+
else
|
|
18
|
+
""
|
|
19
|
+
end
|
|
20
|
+
end
|
|
10
21
|
end
|
|
11
22
|
end
|
|
12
23
|
|
|
13
24
|
class Test::Command
|
|
14
25
|
##
|
|
15
|
-
# Test::Command#
|
|
16
|
-
class
|
|
17
|
-
def
|
|
26
|
+
# Test::Command#arguments
|
|
27
|
+
class ArgumentsTest < Test
|
|
28
|
+
def test_ruby_arguments
|
|
18
29
|
assert_equal "42\n", ::Test::Command.new("ruby")
|
|
19
|
-
.
|
|
30
|
+
.arguments("-e", "warn 42")
|
|
20
31
|
.stderr
|
|
21
32
|
end
|
|
22
33
|
|
|
23
|
-
def
|
|
34
|
+
def test_ruby_arguments_to_s
|
|
24
35
|
arg = Object.new
|
|
25
36
|
def arg.to_s = "-e"
|
|
26
37
|
assert_equal "42\n", ::Test::Command.new("ruby")
|
|
27
|
-
.
|
|
38
|
+
.arguments(arg, "warn 42")
|
|
39
|
+
.stderr
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_ruby_arguments_argv_alias
|
|
43
|
+
assert_equal "42\n", ::Test::Command.new("ruby")
|
|
44
|
+
.argv("-e", "warn 42")
|
|
28
45
|
.stderr
|
|
29
46
|
end
|
|
30
47
|
end
|
|
@@ -40,15 +57,15 @@ class Test::Command
|
|
|
40
57
|
end
|
|
41
58
|
|
|
42
59
|
def test_ruby_env_only_given_keys
|
|
43
|
-
assert_equal "BAR\nFOO\nPATH\n",
|
|
60
|
+
assert_equal "BAR\nFOO\nPATH\n#{macos}",
|
|
44
61
|
::Test::Command.new("ruby", "-e", "puts ENV.keys.sort")
|
|
45
62
|
.env("FOO" => "42", "BAR" => "7")
|
|
46
63
|
.stdout
|
|
47
64
|
end
|
|
48
65
|
|
|
49
66
|
def test_ruby_env_empty_is_empty_env
|
|
50
|
-
assert_equal "PATH",
|
|
51
|
-
::Test::Command.new("ruby", "-e", "
|
|
67
|
+
assert_equal "PATH\n#{macos}",
|
|
68
|
+
::Test::Command.new("ruby", "-e", "puts ENV.keys.sort")
|
|
52
69
|
.env({})
|
|
53
70
|
.stdout
|
|
54
71
|
end
|
|
@@ -222,5 +239,27 @@ class Test::Command
|
|
|
222
239
|
assert_equal true, ::Test::Command.new("/a/path/that/is/not/found").command_not_found?
|
|
223
240
|
assert_equal true, ::Test::Command.new("/a/path/that/is/not/found").not_found?
|
|
224
241
|
end
|
|
242
|
+
|
|
243
|
+
def test_spawn_returns_self_when_not_found
|
|
244
|
+
command = ::Test::Command.new("/a/path/that/is/not/found")
|
|
245
|
+
assert_equal command, command.spawn
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def test_spawn_sets_not_found_on_self
|
|
249
|
+
command = ::Test::Command.new("/a/path/that/is/not/found")
|
|
250
|
+
command.spawn
|
|
251
|
+
assert_equal true, command.not_found?
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def test_stdout_when_not_found
|
|
255
|
+
command = ::Test::Command.new("/a/path/that/is/not/found")
|
|
256
|
+
assert_equal "", command.stdout
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def test_stderr_when_not_found
|
|
260
|
+
command = ::Test::Command.new("/a/path/that/is/not/found")
|
|
261
|
+
assert_equal "No such file or directory - /a/path/that/is/not/found",
|
|
262
|
+
command.stderr
|
|
263
|
+
end
|
|
225
264
|
end
|
|
226
265
|
end
|
data/test-cmd.rb.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
|
6
6
|
gem.name = "test-cmd.rb"
|
|
7
7
|
gem.authors = ["Robert Gleeson"]
|
|
8
8
|
gem.email = ["robert@r.uby.dev"]
|
|
9
|
-
gem.homepage = "https://github.com/
|
|
9
|
+
gem.homepage = "https://github.com/r-uby-dev/test-cmd.rb#readme"
|
|
10
10
|
gem.version = Test::Command::VERSION
|
|
11
11
|
gem.required_ruby_version = ">= 3.0"
|
|
12
12
|
gem.licenses = ["MIT"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: test-cmd.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Gleeson
|
|
@@ -106,7 +106,7 @@ files:
|
|
|
106
106
|
- test-cmd.rb.gemspec
|
|
107
107
|
- test/cmd_test.rb
|
|
108
108
|
- test/setup.rb
|
|
109
|
-
homepage: https://github.com/
|
|
109
|
+
homepage: https://github.com/r-uby-dev/test-cmd.rb#readme
|
|
110
110
|
licenses:
|
|
111
111
|
- MIT
|
|
112
112
|
metadata: {}
|
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
125
|
version: '0'
|
|
126
126
|
requirements: []
|
|
127
|
-
rubygems_version: 4.0.
|
|
127
|
+
rubygems_version: 4.0.20
|
|
128
128
|
specification_version: 4
|
|
129
129
|
summary: test-cmd.rb is a Go-inspired, object-oriented interface for running commands
|
|
130
130
|
on UNIX-like systems, in the spirit of Go's `os/exec`. A command can be built by
|