pups 1.3.0 → 1.4.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/CHANGELOG +4 -0
- data/lib/pups/exec_command.rb +16 -9
- data/lib/pups/version.rb +1 -1
- data/test/exec_command_test.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c44dd2f8d1c107d585ee7c21a15dfb4061f6dafd78a07f8f937e416fc2f267ee
|
|
4
|
+
data.tar.gz: 99dc03350563acc46ae7df3566bf647db604572b31b8b46d46579acba6a9b880
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fdac187b13809df0c9b6c6dc34d74b17e2c360dcdf84e9f60a01a9f9d57f813a618a2ab99689a65a4998cf38e6ae98e01504aac9224bf81b5096a415dda0973f
|
|
7
|
+
data.tar.gz: 1668338d3b167b277cfcb09c063f7489101cfc4470e2b00d5c1d36d46fd0e8eb4e8149a33ab0ff11780f50060c9efee3f948fa203785da596ea74329356d1e0d
|
data/CHANGELOG
CHANGED
data/lib/pups/exec_command.rb
CHANGED
|
@@ -111,17 +111,24 @@ module Pups
|
|
|
111
111
|
return pid
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
opts = { out: $stdout, err: $stderr }
|
|
115
|
+
|
|
116
|
+
if stdin
|
|
117
|
+
reader, writer = IO.pipe
|
|
118
|
+
opts[:in] = reader
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
pid = Process.spawn(command, opts)
|
|
122
|
+
|
|
123
|
+
if stdin
|
|
124
|
+
reader.close
|
|
125
|
+
Pups.log.info(stdin)
|
|
126
|
+
writer.write(stdin)
|
|
127
|
+
writer.close
|
|
123
128
|
end
|
|
124
129
|
|
|
130
|
+
Process.wait(pid)
|
|
131
|
+
|
|
125
132
|
unless $CHILD_STATUS == 0
|
|
126
133
|
err =
|
|
127
134
|
Pups::ExecError.new(
|
data/lib/pups/version.rb
CHANGED
data/test/exec_command_test.rb
CHANGED
|
@@ -98,5 +98,44 @@ module Pups
|
|
|
98
98
|
|
|
99
99
|
assert_raises(Errno::ECHILD) { Process.waitpid(pid, Process::WNOHANG) }
|
|
100
100
|
end
|
|
101
|
+
|
|
102
|
+
def test_stdout_streaming
|
|
103
|
+
# Starts a long-running process that outputs immediately
|
|
104
|
+
# and then watches a file before quitting.
|
|
105
|
+
# If stdout is properly streamed, we should see the output
|
|
106
|
+
# immediately rather than waiting for the process to end.
|
|
107
|
+
|
|
108
|
+
signal_file = Tempfile.new("signal")
|
|
109
|
+
signal_path = signal_file.path
|
|
110
|
+
signal_file.close
|
|
111
|
+
|
|
112
|
+
reader, writer = IO.pipe
|
|
113
|
+
original_stdout = $stdout.dup
|
|
114
|
+
|
|
115
|
+
$stdout.reopen(writer)
|
|
116
|
+
|
|
117
|
+
cmd = ExecCommand.new({})
|
|
118
|
+
cmd.add("echo 'streamed output'; while [ ! -s #{signal_path} ]; do sleep 0.1; done")
|
|
119
|
+
|
|
120
|
+
thread = Thread.new { cmd.run }
|
|
121
|
+
|
|
122
|
+
# Wait for output - if streaming works, it appears immediately
|
|
123
|
+
# If buffered, it would never appear since command loops until signaled
|
|
124
|
+
ready = IO.select([reader], nil, nil, 2)
|
|
125
|
+
assert ready, "Output should be available before command completes"
|
|
126
|
+
|
|
127
|
+
output = reader.read_nonblock(1000)
|
|
128
|
+
assert_includes(output, "streamed output")
|
|
129
|
+
ensure
|
|
130
|
+
$stdout.reopen(original_stdout) if original_stdout
|
|
131
|
+
|
|
132
|
+
writer&.close
|
|
133
|
+
reader&.close
|
|
134
|
+
|
|
135
|
+
File.write(signal_path, "done")
|
|
136
|
+
signal_file&.unlink
|
|
137
|
+
|
|
138
|
+
thread.join(2)
|
|
139
|
+
end
|
|
101
140
|
end
|
|
102
141
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pups
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Saffron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|