test-cmd.rb 1.2.0 → 2.1.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/README.md +81 -30
- data/lib/test/cmd.rb +23 -22
- data/rubydev.svg +185 -0
- data/test/cmd_test.rb +25 -14
- data/test-cmd.rb.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92d0cf20a1d63472f4ac178bcb7b74b05d2e5875fe05bccb56f9decbcccd691a
|
|
4
|
+
data.tar.gz: '0318fb0281b874accf7f44c6f4a3c2320d3aa4a3405829a36430347f8d65a9c4'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4daa335326b92120051a40666c07d8b731f447b45e01a73bc5e1cbb2eac65d53e4e4bb87d3ded462b6375b86e85bbe15419d1b8e64642c5f1a60659427456401
|
|
7
|
+
data.tar.gz: '0859457b884abaafc8ea53ecc2fd238c4c111b2f6175f177d85ab48b1378de7bc81556160a06433ba900e59d0513b7e910e060944f99fb7d8db6b57182e5e15f'
|
data/README.md
CHANGED
|
@@ -1,35 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://r.uby.dev">
|
|
3
|
+
<img
|
|
4
|
+
src="rubydev.svg"
|
|
5
|
+
width="400"
|
|
6
|
+
height="200"
|
|
7
|
+
border="0"
|
|
8
|
+
alt="a r.uby.dev project"
|
|
9
|
+
>
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
> A [r.uby.dev](https://r.uby.dev) project.
|
|
14
|
+
|
|
15
|
+
Welcome to the canonical test-cmd.rb repository.
|
|
16
|
+
|
|
17
|
+
test-cmd.rb is a Go-inspired, object-oriented interface for running
|
|
18
|
+
commands on UNIX-like systems, in the spirit of Go's `os/exec`. A
|
|
19
|
+
command is built up and then spawned so its standard output and
|
|
20
|
+
error streams, process ID, and exit status are captured in the
|
|
21
|
+
background. Predicates, callbacks, and process control cover the
|
|
22
|
+
common cases with a small and dependency-free API.
|
|
2
23
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
test-cmd.rb can be installed via rubygems.org:
|
|
27
|
+
|
|
28
|
+
gem install test-cmd.rb
|
|
6
29
|
|
|
7
|
-
##
|
|
30
|
+
## Quick start
|
|
8
31
|
|
|
9
32
|
### Commands
|
|
10
33
|
|
|
11
|
-
|
|
34
|
+
A command is created with
|
|
35
|
+
[`Test::Command#initialize`](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html#initialize-instance_method)
|
|
36
|
+
which takes the name or path of a command, and given additional
|
|
37
|
+
arguments with
|
|
38
|
+
[`Test::Command#argv`](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html#argv-instance_method).
|
|
39
|
+
Environment variables can be set for the spawned process with
|
|
40
|
+
[`Test::Command#env`](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html#env-instance_method).
|
|
41
|
+
The instance has access to the command's process ID, exit status,
|
|
42
|
+
standard output stream, and standard error stream.
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
require "test-cmd"
|
|
46
|
+
puts Test::Command.new("ls").argv("-l").stdout
|
|
47
|
+
puts Test::Command.new("env").env("FOO" => "bar").stdout
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<details>
|
|
51
|
+
<summary>Environment</summary>
|
|
52
|
+
<br>
|
|
53
|
+
|
|
54
|
+
Environment variables for the spawned process are set with
|
|
55
|
+
[`Test::Command#env`](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html#env-instance_method),
|
|
56
|
+
which merges the given variables into the child's environment and
|
|
57
|
+
returns the command for chaining.
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
require "test-cmd"
|
|
61
|
+
puts Test::Command
|
|
62
|
+
.new("ruby", "-e", "puts ENV['FOO']")
|
|
63
|
+
.env("FOO" => "42")
|
|
64
|
+
.stdout # => "42\n"
|
|
65
|
+
```
|
|
66
|
+
</details>
|
|
67
|
+
|
|
68
|
+
<details>
|
|
69
|
+
<summary>Callbacks</summary>
|
|
70
|
+
<br>
|
|
12
71
|
|
|
13
72
|
The success and failure callbacks provide hooks for when
|
|
14
73
|
a command exits successfully or unsuccessfully. The callbacks
|
|
15
74
|
are passed an instance of
|
|
16
|
-
[Test::
|
|
75
|
+
[Test::Command](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html)
|
|
17
76
|
that has access to the command's process ID, exit status,
|
|
18
|
-
standard
|
|
77
|
+
standard output stream, and standard error stream.
|
|
19
78
|
|
|
20
|
-
```
|
|
79
|
+
```ruby
|
|
21
80
|
require "test-cmd"
|
|
22
|
-
|
|
81
|
+
Test::Command.new("ruby", "-e", "exit 0")
|
|
23
82
|
.success { print "The command [#{_1.pid}] was successful", "\n" }
|
|
24
83
|
.failure { print "The command [#{_1.pid}] was unsuccessful", "\n" }
|
|
25
84
|
```
|
|
85
|
+
</details>
|
|
26
86
|
|
|
27
|
-
|
|
87
|
+
<details>
|
|
88
|
+
<summary>Assertions</summary>
|
|
89
|
+
<br>
|
|
28
90
|
|
|
29
91
|
The following example demonstrates how tests might be written with
|
|
30
|
-
test-unit from the standard library.
|
|
31
|
-
[
|
|
32
|
-
|
|
92
|
+
test-unit from the standard library. A
|
|
93
|
+
[Test::Command](https://r.uby.dev/api-docs/test-cmd.rb/Test/Command.html)
|
|
94
|
+
takes the name or path of a command, alongside any arguments. The tests
|
|
33
95
|
assert against the exit status, standard output stream, and standard error
|
|
34
96
|
stream of the spawned ruby process:
|
|
35
97
|
|
|
@@ -57,29 +119,18 @@ class CmdTest < Test::Unit::TestCase
|
|
|
57
119
|
private
|
|
58
120
|
|
|
59
121
|
def ruby(code)
|
|
60
|
-
|
|
122
|
+
Test::Command.new("ruby", "-e", code)
|
|
61
123
|
end
|
|
62
124
|
end
|
|
63
125
|
```
|
|
126
|
+
</details>
|
|
64
127
|
|
|
65
128
|
## Documentation
|
|
66
129
|
|
|
67
130
|
A complete API reference is available at
|
|
68
|
-
[
|
|
69
|
-
|
|
70
|
-
## Install
|
|
71
|
-
|
|
72
|
-
test-cmd.rb can be installed via rubygems.org:
|
|
73
|
-
|
|
74
|
-
gem install test-cmd.rb
|
|
75
|
-
|
|
76
|
-
## Sources
|
|
77
|
-
|
|
78
|
-
* [github.com/@0x1eef](https://github.com/0x1eef/test-cmd.rb#readme)
|
|
79
|
-
* [gitlab.com/@0x1eef](https://gitlab.com/0x1eef/test-cmd.rb#about)
|
|
131
|
+
[r.uby.dev/api-docs/test-cmd.rb](https://r.uby.dev/api-docs/test-cmd.rb)
|
|
80
132
|
|
|
81
133
|
## License
|
|
82
134
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
See [LICENSE](./LICENSE)
|
|
135
|
+
This software is released under the terms of the BSD Zero Clause license. <br>
|
|
136
|
+
See [LICENSE](./LICENSE) for details.
|
data/lib/test/cmd.rb
CHANGED
|
@@ -4,7 +4,7 @@ end unless defined?(Test)
|
|
|
4
4
|
##
|
|
5
5
|
# test-cmd.rb provides an object oriented interface
|
|
6
6
|
# for spawning a command
|
|
7
|
-
class Test::
|
|
7
|
+
class Test::Command
|
|
8
8
|
##
|
|
9
9
|
# @api private
|
|
10
10
|
class Pipe < Struct.new(:r, :w)
|
|
@@ -22,10 +22,11 @@ class Test::Cmd
|
|
|
22
22
|
# A command to spawn
|
|
23
23
|
# @param [Array<String>] argv
|
|
24
24
|
# Zero or more command-line arguments
|
|
25
|
-
# @return [Test::
|
|
25
|
+
# @return [Test::Command]
|
|
26
26
|
def initialize(cmd, *argv)
|
|
27
27
|
@cmd = cmd
|
|
28
28
|
@argv = argv.dup
|
|
29
|
+
@env = {}
|
|
29
30
|
@status = nil
|
|
30
31
|
@spawned = false
|
|
31
32
|
@stdout = ""
|
|
@@ -36,14 +37,22 @@ class Test::Cmd
|
|
|
36
37
|
##
|
|
37
38
|
# @param [Array<String, #to_s>] argv
|
|
38
39
|
# Command-line arguments
|
|
39
|
-
# @return [Test::
|
|
40
|
+
# @return [Test::Command]
|
|
40
41
|
def argv(*argv)
|
|
41
42
|
tap { @argv.concat(argv) }
|
|
42
43
|
end
|
|
43
44
|
|
|
45
|
+
##
|
|
46
|
+
# @param [Hash{String => String}] env
|
|
47
|
+
# Environment variables to set for the spawned command
|
|
48
|
+
# @return [Test::Command]
|
|
49
|
+
def env(env)
|
|
50
|
+
tap { @env.merge!(env) }
|
|
51
|
+
end
|
|
52
|
+
|
|
44
53
|
##
|
|
45
54
|
# Spawns a command
|
|
46
|
-
# @return [Test::
|
|
55
|
+
# @return [Test::Command]
|
|
47
56
|
def spawn
|
|
48
57
|
return self if @spawned
|
|
49
58
|
tap do
|
|
@@ -57,6 +66,7 @@ class Test::Cmd
|
|
|
57
66
|
# streams with whole-buffer reads rather than a byte at
|
|
58
67
|
# a time.
|
|
59
68
|
@pid = Process.spawn(
|
|
69
|
+
@env,
|
|
60
70
|
@cmd, *@argv,
|
|
61
71
|
{out: @out.w, err: @err.w, in: IO::NULL}
|
|
62
72
|
)
|
|
@@ -175,13 +185,13 @@ class Test::Cmd
|
|
|
175
185
|
# @group Callbacks
|
|
176
186
|
|
|
177
187
|
##
|
|
178
|
-
# @yieldparam [Test::
|
|
179
|
-
# Yields an instance of {Test::
|
|
188
|
+
# @yieldparam [Test::Command] cmd
|
|
189
|
+
# Yields an instance of {Test::Command Test::Command}
|
|
180
190
|
# @example
|
|
181
|
-
#
|
|
191
|
+
# Test::Command.new("ruby", "-e", "exit 0").success do
|
|
182
192
|
# print "ok pid #{_1.pid}", "\n"
|
|
183
193
|
# end
|
|
184
|
-
# @return [Test::
|
|
194
|
+
# @return [Test::Command]
|
|
185
195
|
def success
|
|
186
196
|
tap do
|
|
187
197
|
spawn
|
|
@@ -191,13 +201,13 @@ class Test::Cmd
|
|
|
191
201
|
end
|
|
192
202
|
|
|
193
203
|
##
|
|
194
|
-
# @yieldparam [Test::
|
|
195
|
-
# Yields an instance of {Test::
|
|
204
|
+
# @yieldparam [Test::Command] cmd
|
|
205
|
+
# Yields an instance of {Test::Command Test::Command}
|
|
196
206
|
# @example
|
|
197
|
-
#
|
|
207
|
+
# Test::Command.new("ruby", "-e", "exit 1").failure do
|
|
198
208
|
# print "fail pid #{_1.pid}", "\n"
|
|
199
209
|
# end
|
|
200
|
-
# @return [Test::
|
|
210
|
+
# @return [Test::Command]
|
|
201
211
|
def failure
|
|
202
212
|
tap do
|
|
203
213
|
spawn
|
|
@@ -218,13 +228,4 @@ class Test::Cmd
|
|
|
218
228
|
return unless @producer&.alive?
|
|
219
229
|
@producer.join
|
|
220
230
|
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
module Kernel
|
|
224
|
-
##
|
|
225
|
-
# @param (see Test::Cmd#initialize)
|
|
226
|
-
# @return (see Test::Cmd#initialize)
|
|
227
|
-
def cmd(cmd, *argv)
|
|
228
|
-
Test::Cmd.new(cmd, *argv)
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
+
end
|
data/rubydev.svg
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 560 220" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">r.uby.dev</title>
|
|
3
|
+
<desc id="desc">A wide r.uby.dev wordmark with three small ruby gemstones moving around the text.</desc>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="body" x1="45" y1="35" x2="211" y2="224" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop offset="0" stop-color="#ff7468"/>
|
|
7
|
+
<stop offset="0.42" stop-color="#cc342d"/>
|
|
8
|
+
<stop offset="1" stop-color="#5b090d"/>
|
|
9
|
+
</linearGradient>
|
|
10
|
+
<linearGradient id="table" x1="75" y1="31" x2="166" y2="104" gradientUnits="userSpaceOnUse">
|
|
11
|
+
<stop offset="0" stop-color="#fff3ec"/>
|
|
12
|
+
<stop offset="0.26" stop-color="#ff8f84"/>
|
|
13
|
+
<stop offset="1" stop-color="#d62f2c"/>
|
|
14
|
+
</linearGradient>
|
|
15
|
+
<linearGradient id="right" x1="150" y1="59" x2="219" y2="195" gradientUnits="userSpaceOnUse">
|
|
16
|
+
<stop offset="0" stop-color="#bb2026"/>
|
|
17
|
+
<stop offset="1" stop-color="#3c0407"/>
|
|
18
|
+
</linearGradient>
|
|
19
|
+
<linearGradient id="center" x1="99" y1="104" x2="146" y2="226" gradientUnits="userSpaceOnUse">
|
|
20
|
+
<stop offset="0" stop-color="#ff6c61"/>
|
|
21
|
+
<stop offset="0.48" stop-color="#c82d2a"/>
|
|
22
|
+
<stop offset="1" stop-color="#8d1618"/>
|
|
23
|
+
</linearGradient>
|
|
24
|
+
<radialGradient id="glow" cx="38%" cy="22%" r="66%">
|
|
25
|
+
<stop offset="0" stop-color="#fff8ed" stop-opacity="0.68"/>
|
|
26
|
+
<stop offset="0.42" stop-color="#ffb0a7" stop-opacity="0.18"/>
|
|
27
|
+
<stop offset="1" stop-color="#ffb0a7" stop-opacity="0"/>
|
|
28
|
+
</radialGradient>
|
|
29
|
+
<linearGradient id="wordmark" x1="0" y1="76" x2="0" y2="138" gradientUnits="userSpaceOnUse">
|
|
30
|
+
<stop offset="0" stop-color="#ffffff"/>
|
|
31
|
+
<stop offset="0.48" stop-color="#e1e4e8"/>
|
|
32
|
+
<stop offset="1" stop-color="#aeb8c2"/>
|
|
33
|
+
</linearGradient>
|
|
34
|
+
<linearGradient id="accentLine" x1="90" y1="0" x2="470" y2="0" gradientUnits="userSpaceOnUse">
|
|
35
|
+
<stop offset="0" stop-color="#30363d"/>
|
|
36
|
+
<stop offset="0.5" stop-color="#cc342d"/>
|
|
37
|
+
<stop offset="1" stop-color="#30363d"/>
|
|
38
|
+
</linearGradient>
|
|
39
|
+
<filter id="shadow" x="-18%" y="-18%" width="136%" height="146%">
|
|
40
|
+
<feDropShadow dx="0" dy="10" stdDeviation="9" flood-color="#000" flood-opacity="0.34"/>
|
|
41
|
+
</filter>
|
|
42
|
+
<filter id="textShadow" x="-20%" y="-45%" width="140%" height="190%">
|
|
43
|
+
<feDropShadow dx="0" dy="7" stdDeviation="6" flood-color="#000" flood-opacity="0.55"/>
|
|
44
|
+
</filter>
|
|
45
|
+
<symbol id="gemstone" viewBox="0 0 256 256">
|
|
46
|
+
<path d="M33 91 78 30h100l45 61-95 134Z" fill="url(#body)" stroke="#250507" stroke-width="7" stroke-linejoin="round"/>
|
|
47
|
+
<path d="M78 30h100l-50 61Z" fill="url(#table)" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
48
|
+
<path d="M33 91h95l-52 44Z" fill="#e93c35" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
49
|
+
<path d="M223 91h-95l52 44Z" fill="url(#right)" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
50
|
+
<path d="M76 135 128 225 33 91Z" fill="#9f1b1d" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
51
|
+
<path d="M180 135 128 225 223 91Z" fill="#62080d" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
52
|
+
<path d="M76 135h104l-52 90Z" fill="url(#center)" stroke="#250507" stroke-width="4" stroke-linejoin="round"/>
|
|
53
|
+
<path d="M78 30 128 91 76 135 33 91Z" fill="#d9322d" opacity="0.72"/>
|
|
54
|
+
<path d="M178 30 128 91 180 135 223 91Z" fill="#8f1519" opacity="0.72"/>
|
|
55
|
+
<path d="M128 91 76 135h104Z" fill="#ff6257" opacity="0.5"/>
|
|
56
|
+
<path d="M49 91 84 43h43L86 96Z" fill="url(#glow)"/>
|
|
57
|
+
<path d="M85 62 101 43h35L93 87Z" fill="#fff6eb" opacity="0.52"/>
|
|
58
|
+
<path d="M97 153h62" fill="none" stroke="#ffaba2" stroke-width="4" stroke-linecap="round" opacity="0.25"/>
|
|
59
|
+
</symbol>
|
|
60
|
+
</defs>
|
|
61
|
+
<style>
|
|
62
|
+
svg {
|
|
63
|
+
color-scheme: light dark;
|
|
64
|
+
--wordmark-fill: #24292f;
|
|
65
|
+
--wordmark-halo: #ffffff;
|
|
66
|
+
--wordmark-outline: #d0d7de;
|
|
67
|
+
--rule: #d0d7de;
|
|
68
|
+
--rule-strong: #8c959f;
|
|
69
|
+
--accent-shadow: #d0d7de;
|
|
70
|
+
}
|
|
71
|
+
.wordmark-halo {
|
|
72
|
+
fill: none;
|
|
73
|
+
stroke: var(--wordmark-halo);
|
|
74
|
+
stroke-width: 16;
|
|
75
|
+
stroke-linejoin: round;
|
|
76
|
+
paint-order: stroke;
|
|
77
|
+
}
|
|
78
|
+
.wordmark-outline {
|
|
79
|
+
fill: none;
|
|
80
|
+
stroke: var(--wordmark-outline);
|
|
81
|
+
stroke-width: 8;
|
|
82
|
+
stroke-linejoin: round;
|
|
83
|
+
paint-order: stroke;
|
|
84
|
+
}
|
|
85
|
+
.wordmark-fill {
|
|
86
|
+
fill: var(--wordmark-fill);
|
|
87
|
+
}
|
|
88
|
+
.tagline {
|
|
89
|
+
fill: var(--wordmark-fill);
|
|
90
|
+
opacity: 0.78;
|
|
91
|
+
}
|
|
92
|
+
.rule {
|
|
93
|
+
stroke: var(--rule);
|
|
94
|
+
}
|
|
95
|
+
.rule-strong {
|
|
96
|
+
stroke: var(--rule-strong);
|
|
97
|
+
}
|
|
98
|
+
.accent-shadow {
|
|
99
|
+
stroke: var(--accent-shadow);
|
|
100
|
+
}
|
|
101
|
+
.gem {
|
|
102
|
+
animation-duration: 8.5s;
|
|
103
|
+
animation-iteration-count: infinite;
|
|
104
|
+
animation-timing-function: ease-in-out;
|
|
105
|
+
}
|
|
106
|
+
.gem-a { animation-name: gem-a; }
|
|
107
|
+
.gem-b { animation-name: gem-b; animation-duration: 9.5s; }
|
|
108
|
+
.gem-c { animation-name: gem-c; animation-duration: 10s; }
|
|
109
|
+
.gem-front {
|
|
110
|
+
opacity: 0;
|
|
111
|
+
animation-duration: 18s;
|
|
112
|
+
animation-iteration-count: infinite;
|
|
113
|
+
animation-timing-function: ease-in-out;
|
|
114
|
+
}
|
|
115
|
+
.gem-front-a { animation-name: gem-front-a; }
|
|
116
|
+
.gem-front-b { animation-name: gem-front-b; animation-delay: -6s; }
|
|
117
|
+
.gem-front-c { animation-name: gem-front-c; animation-delay: -12s; }
|
|
118
|
+
@keyframes gem-a {
|
|
119
|
+
0%, 100% { transform: translate(42px, 82px) rotate(-10deg); }
|
|
120
|
+
35% { transform: translate(66px, 45px) rotate(5deg); }
|
|
121
|
+
70% { transform: translate(84px, 118px) rotate(-18deg); }
|
|
122
|
+
}
|
|
123
|
+
@keyframes gem-b {
|
|
124
|
+
0%, 100% { transform: translate(236px, 13px) rotate(3deg); }
|
|
125
|
+
33% { transform: translate(192px, 28px) rotate(-9deg); }
|
|
126
|
+
66% { transform: translate(292px, 24px) rotate(12deg); }
|
|
127
|
+
}
|
|
128
|
+
@keyframes gem-c {
|
|
129
|
+
0%, 100% { transform: translate(430px, 78px) rotate(8deg); }
|
|
130
|
+
38% { transform: translate(397px, 45px) rotate(-4deg); }
|
|
131
|
+
72% { transform: translate(446px, 117px) rotate(16deg); }
|
|
132
|
+
}
|
|
133
|
+
@media (prefers-reduced-motion: reduce) {
|
|
134
|
+
.gem { animation: none; }
|
|
135
|
+
.gem-front { animation: none; opacity: 0; }
|
|
136
|
+
.gem-a { transform: translate(42px, 82px) rotate(-10deg); }
|
|
137
|
+
.gem-b { transform: translate(236px, 13px) rotate(3deg); }
|
|
138
|
+
.gem-c { transform: translate(430px, 78px) rotate(8deg); }
|
|
139
|
+
}
|
|
140
|
+
@keyframes gem-front-a {
|
|
141
|
+
0%, 42%, 51%, 100% { opacity: 0; }
|
|
142
|
+
45%, 48% { opacity: 0.9; }
|
|
143
|
+
}
|
|
144
|
+
@keyframes gem-front-b {
|
|
145
|
+
0%, 57%, 66%, 100% { opacity: 0; }
|
|
146
|
+
60%, 63% { opacity: 0.86; }
|
|
147
|
+
}
|
|
148
|
+
@keyframes gem-front-c {
|
|
149
|
+
0%, 72%, 81%, 100% { opacity: 0; }
|
|
150
|
+
75%, 78% { opacity: 0.88; }
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
153
|
+
|
|
154
|
+
<path class="rule" d="M32 38h496M32 182h496" stroke-width="1" opacity="0.62"/>
|
|
155
|
+
<path class="rule-strong" d="M90 32h380" stroke-width="2" stroke-linecap="round" opacity="0.72"/>
|
|
156
|
+
|
|
157
|
+
<g filter="url(#shadow)" opacity="0.92">
|
|
158
|
+
<g class="gem gem-a"><use href="#gemstone" width="78" height="78"/></g>
|
|
159
|
+
<g class="gem gem-b"><use href="#gemstone" width="84" height="84"/></g>
|
|
160
|
+
<g class="gem gem-c"><use href="#gemstone" width="78" height="78"/></g>
|
|
161
|
+
</g>
|
|
162
|
+
|
|
163
|
+
<g font-family="system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" text-anchor="middle">
|
|
164
|
+
<text class="wordmark-halo" x="280" y="126" fill="none" stroke="#ffffff"
|
|
165
|
+
font-size="72" font-weight="800"
|
|
166
|
+
filter="url(#textShadow)">r.uby.dev</text>
|
|
167
|
+
<text class="wordmark-outline" x="280" y="126" fill="none" stroke="#d0d7de"
|
|
168
|
+
font-size="72" font-weight="800">r.uby.dev</text>
|
|
169
|
+
<text class="wordmark-fill" x="280" y="126" fill="#24292f"
|
|
170
|
+
font-size="72" font-weight="800">r.uby.dev</text>
|
|
171
|
+
</g>
|
|
172
|
+
|
|
173
|
+
<g filter="url(#shadow)">
|
|
174
|
+
<g class="gem gem-a"><use class="gem-front gem-front-a" href="#gemstone" width="78" height="78"/></g>
|
|
175
|
+
<g class="gem gem-b"><use class="gem-front gem-front-b" href="#gemstone" width="84" height="84"/></g>
|
|
176
|
+
<g class="gem gem-c"><use class="gem-front gem-front-c" href="#gemstone" width="78" height="78"/></g>
|
|
177
|
+
</g>
|
|
178
|
+
|
|
179
|
+
<path class="accent-shadow" d="M90 176h380" stroke-width="8" stroke-linecap="round"/>
|
|
180
|
+
<path d="M90 176h380" stroke="url(#accentLine)" stroke-width="4" stroke-linecap="round"/>
|
|
181
|
+
<circle cx="280" cy="176" r="5" fill="#cc342d"/>
|
|
182
|
+
<text class="tagline" x="280" y="204"
|
|
183
|
+
font-family="system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
184
|
+
text-anchor="middle" font-size="18" font-weight="650">Building cool stuff with Ruby</text>
|
|
185
|
+
</svg>
|
data/test/cmd_test.rb
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
require_relative "setup"
|
|
2
2
|
|
|
3
|
-
class Test::
|
|
3
|
+
class Test::Command
|
|
4
4
|
class Test < Test::Unit::TestCase
|
|
5
5
|
private
|
|
6
6
|
|
|
7
7
|
def ruby(str)
|
|
8
|
-
|
|
8
|
+
::Test::Command.new "ruby", "-e", str
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
class Test::
|
|
13
|
+
class Test::Command
|
|
14
14
|
##
|
|
15
|
-
# Test::
|
|
15
|
+
# Test::Command#argv
|
|
16
16
|
class ARGVTest < Test
|
|
17
17
|
def test_ruby_argv
|
|
18
|
-
assert_equal "42\n",
|
|
18
|
+
assert_equal "42\n", ::Test::Command.new("ruby")
|
|
19
19
|
.argv("-e", "warn 42")
|
|
20
20
|
.stderr
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
##
|
|
25
|
-
# Test::
|
|
25
|
+
# Test::Command#env
|
|
26
|
+
class EnvTest < Test
|
|
27
|
+
def test_ruby_env
|
|
28
|
+
assert_equal "42\n",
|
|
29
|
+
::Test::Command.new("ruby", "-e", "puts ENV['FOO']")
|
|
30
|
+
.env("FOO" => "42")
|
|
31
|
+
.stdout
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Test::Command#{exit_status, status, success?}
|
|
26
37
|
class ExitStatusTest < Test
|
|
27
38
|
def test_ruby_exit_status_success
|
|
28
39
|
assert_equal 0, ruby("exit 0").exit_status
|
|
@@ -38,12 +49,12 @@ class Test::Cmd
|
|
|
38
49
|
end
|
|
39
50
|
|
|
40
51
|
def test_nonexistent_command
|
|
41
|
-
assert_equal false,
|
|
52
|
+
assert_equal false, ::Test::Command.new("/a/path/that/is/not/found").success?
|
|
42
53
|
end
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
##
|
|
46
|
-
# Test::
|
|
57
|
+
# Test::Command#{stdout,stderr}
|
|
47
58
|
class OutputTest < Test
|
|
48
59
|
def test_ruby_stdout
|
|
49
60
|
assert_equal "42\n", ruby("puts 42").stdout
|
|
@@ -68,12 +79,12 @@ class Test::Cmd
|
|
|
68
79
|
|
|
69
80
|
def test_nonexistent_command
|
|
70
81
|
assert_equal "No such file or directory - /a/path/that/is/not/found",
|
|
71
|
-
|
|
82
|
+
::Test::Command.new("/a/path/that/is/not/found").stderr
|
|
72
83
|
end
|
|
73
84
|
end
|
|
74
85
|
|
|
75
86
|
##
|
|
76
|
-
# Test::
|
|
87
|
+
# Test::Command#{success, failure}
|
|
77
88
|
class CallbackTest < Test
|
|
78
89
|
def test_ruby_success_callback
|
|
79
90
|
call_ok, call_fail = [false, false]
|
|
@@ -95,7 +106,7 @@ class Test::Cmd
|
|
|
95
106
|
end
|
|
96
107
|
|
|
97
108
|
##
|
|
98
|
-
# Test::
|
|
109
|
+
# Test::Command#spawned?
|
|
99
110
|
class SpawnedTest < Test
|
|
100
111
|
def test_spawned_before_spawn
|
|
101
112
|
assert_equal false, ruby("puts 42").spawned?
|
|
@@ -107,11 +118,11 @@ class Test::Cmd
|
|
|
107
118
|
end
|
|
108
119
|
|
|
109
120
|
##
|
|
110
|
-
# Test::
|
|
121
|
+
# Test::Command#command_not_found?
|
|
111
122
|
class CommandNotFoundTest < Test
|
|
112
123
|
def test_command_not_found
|
|
113
|
-
assert_equal true,
|
|
114
|
-
assert_equal true,
|
|
124
|
+
assert_equal true, ::Test::Command.new("/a/path/that/is/not/found").command_not_found?
|
|
125
|
+
assert_equal true, ::Test::Command.new("/a/path/that/is/not/found").not_found?
|
|
115
126
|
end
|
|
116
127
|
end
|
|
117
128
|
end
|
data/test-cmd.rb.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
|
5
5
|
gem.authors = ["robert"]
|
|
6
6
|
gem.email = ["robert@r.uby.dev"]
|
|
7
7
|
gem.homepage = "https://github.com/0x1eef/test-cmd.rb#readme"
|
|
8
|
-
gem.version = "1.
|
|
8
|
+
gem.version = "2.1.0"
|
|
9
9
|
gem.required_ruby_version = ">= 3.0"
|
|
10
10
|
gem.licenses = ["0BSD"]
|
|
11
11
|
gem.files = `git ls-files`.split($/)
|
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: 1.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- robert
|
|
@@ -96,6 +96,7 @@ files:
|
|
|
96
96
|
- Rakefile.rb
|
|
97
97
|
- lib/test-cmd.rb
|
|
98
98
|
- lib/test/cmd.rb
|
|
99
|
+
- rubydev.svg
|
|
99
100
|
- test-cmd.rb.gemspec
|
|
100
101
|
- test/cmd_test.rb
|
|
101
102
|
- test/setup.rb
|