posix-spawn 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8872619c1e0a6be3084be820d80626418a206467
4
- data.tar.gz: 638918f1cc5c4ac96318aef573e73b9b4ceae4de
3
+ metadata.gz: 88d9e42c2e091d60ef6bfaa4bee93671bfa7cdf1
4
+ data.tar.gz: 0c34d4025ca8b876345fea00bb45a152b6909c10
5
5
  SHA512:
6
- metadata.gz: fe6792783174e8d08ab89ca52d792d285167ae3e28f49899f913e8e596b0ad3c986f4c6661e482741f2c2ca85e2ceab8c934db731d524212097a6d52f946fed1
7
- data.tar.gz: ddb22efef13631d5a7c72afa73789f87db199b31918c33f44e280459f2410168d3a194fe987f839b20b202d1d664f16e39d3991b67b5c4e8fc17f62edd9e3a9d
6
+ metadata.gz: 6204dd64bc24a24a7ac155f8f7a0f018860b850b94efc68a68aa6b286a0de3a179deccb6f96ae7b1410045dface4de63aca14d235b1322bfac61399d825b65ff
7
+ data.tar.gz: 988a0574b69a3accddfbb739c89b3da9949146cf7f316f41e2dc364c4ef5bb3cf7ae69858fe9c0318336e946cfc929a1c77178287e742db5a820044f4d680eee
data/Rakefile CHANGED
@@ -26,6 +26,7 @@ task :build => :compile
26
26
 
27
27
  require 'rake/testtask'
28
28
  Rake::TestTask.new 'test' do |t|
29
+ t.libs << "test"
29
30
  t.test_files = FileList['test/test_*.rb']
30
31
  end
31
32
  task :test => :build
@@ -1,7 +1,7 @@
1
1
  require 'mkmf'
2
2
 
3
3
  # warnings save lives
4
- $CFLAGS << " -Wall "
4
+ $CFLAGS << " -Wall " if RbConfig::CONFIG['GCC'] != ""
5
5
 
6
6
  if RUBY_PLATFORM =~ /(mswin|mingw|cygwin|bccwin)/
7
7
  File.open('Makefile','w'){|f| f.puts "default: \ninstall: " }
@@ -212,8 +212,10 @@ module POSIX
212
212
  if fd?(val)
213
213
  val = fd_to_io(val)
214
214
  key.reopen(val)
215
- key.close_on_exec = false
216
- val.close_on_exec = false
215
+ if key.respond_to?(:close_on_exec=)
216
+ key.close_on_exec = false
217
+ val.close_on_exec = false
218
+ end
217
219
  elsif val == :close
218
220
  if key.respond_to?(:close_on_exec=)
219
221
  key.close_on_exec = true
@@ -240,7 +242,12 @@ module POSIX
240
242
  Process::setpgid(0, pgroup) if pgroup
241
243
 
242
244
  # do the deed
243
- ::Kernel::exec(*argv, :close_others=>false)
245
+ if RUBY_VERSION =~ /\A1\.8/
246
+ ::Kernel::exec(*argv)
247
+ else
248
+ argv_and_options = argv + [{:close_others=>false}]
249
+ ::Kernel::exec(*argv_and_options)
250
+ end
244
251
  ensure
245
252
  exit!(127)
246
253
  end
@@ -271,7 +278,8 @@ module POSIX
271
278
  # Returns the String output of the command.
272
279
  def `(cmd)
273
280
  r, w = IO.pipe
274
- pid = spawn(*system_command_prefixes, cmd, :out => w, r => :close)
281
+ command_and_args = system_command_prefixes + [cmd, {:out => w, r => :close}]
282
+ pid = spawn(*command_and_args)
275
283
 
276
284
  if pid > 0
277
285
  w.close
@@ -523,7 +531,8 @@ module POSIX
523
531
  def adjust_process_spawn_argv(args)
524
532
  if args.size == 1 && args[0] =~ /[ |>]/
525
533
  # single string with these characters means run it through the shell
526
- [*system_command_prefixes, args[0]]
534
+ command_and_args = system_command_prefixes + [args[0]]
535
+ [*command_and_args]
527
536
  elsif !args[0].respond_to?(:to_ary)
528
537
  # [argv0, argv1, ...]
529
538
  [[args[0], args[0]], *args[1..-1]]
@@ -113,7 +113,7 @@ module POSIX
113
113
  else
114
114
  {}
115
115
  end
116
- new(*args, { :noexec => true }.merge(options))
116
+ new(*(args + [{ :noexec => true }.merge(options)]))
117
117
  end
118
118
 
119
119
  # All data written to the child process's stdout stream as a String.
@@ -1,5 +1,5 @@
1
1
  module POSIX
2
2
  module Spawn
3
- VERSION = '0.3.9'
3
+ VERSION = '0.3.10'
4
4
  end
5
5
  end
@@ -7,13 +7,14 @@ Gem::Specification.new do |s|
7
7
  s.summary = 'posix_spawnp(2) for ruby'
8
8
  s.description = 'posix-spawn uses posix_spawnp(2) for faster process spawning'
9
9
 
10
- s.homepage = 'http://github.com/rtomayko/posix-spawn'
10
+ s.homepage = 'https://github.com/rtomayko/posix-spawn'
11
11
 
12
12
  s.authors = ['Ryan Tomayko', 'Aman Gupta']
13
13
  s.email = ['r@tomayko.com', 'aman@tmm1.net']
14
- s.license = 'MIT'
14
+ s.licenses = ['MIT', 'LGPL']
15
15
 
16
16
  s.add_development_dependency 'rake-compiler', '0.7.6'
17
+ s.add_development_dependency 'minitest', '>= 4'
17
18
 
18
19
  s.extensions = ['ext/extconf.rb']
19
20
  s.executables << 'posix-spawn-benchmark'
@@ -1,7 +1,6 @@
1
- require 'test/unit'
2
- require 'posix-spawn'
1
+ require 'test_helper'
3
2
 
4
- class BacktickTest < Test::Unit::TestCase
3
+ class BacktickTest < Minitest::Test
5
4
  include POSIX::Spawn
6
5
 
7
6
  def test_backtick_simple
@@ -1,9 +1,8 @@
1
1
  # coding: UTF-8
2
2
 
3
- require 'test/unit'
4
- require 'posix-spawn'
3
+ require 'test_helper'
5
4
 
6
- class ChildTest < Test::Unit::TestCase
5
+ class ChildTest < Minitest::Test
7
6
  include POSIX::Spawn
8
7
 
9
8
  def test_sanity
@@ -57,19 +56,19 @@ class ChildTest < Test::Unit::TestCase
57
56
  end
58
57
 
59
58
  def test_max
60
- assert_raise MaximumOutputExceeded do
59
+ assert_raises MaximumOutputExceeded do
61
60
  Child.new('yes', :max => 100_000)
62
61
  end
63
62
  end
64
63
 
65
64
  def test_max_with_child_hierarchy
66
- assert_raise MaximumOutputExceeded do
65
+ assert_raises MaximumOutputExceeded do
67
66
  Child.new('/bin/sh', '-c', 'yes', :max => 100_000)
68
67
  end
69
68
  end
70
69
 
71
70
  def test_max_with_stubborn_child
72
- assert_raise MaximumOutputExceeded do
71
+ assert_raises MaximumOutputExceeded do
73
72
  Child.new("trap '' TERM; yes", :max => 100_000)
74
73
  end
75
74
  end
@@ -77,7 +76,7 @@ class ChildTest < Test::Unit::TestCase
77
76
  def test_max_with_partial_output
78
77
  p = Child.build('yes', :max => 100_000)
79
78
  assert_nil p.out
80
- assert_raise MaximumOutputExceeded do
79
+ assert_raises MaximumOutputExceeded do
81
80
  p.exec!
82
81
  end
83
82
  assert_output_exceeds_repeated_string("y\n", 100_000, p.out)
@@ -85,7 +84,7 @@ class ChildTest < Test::Unit::TestCase
85
84
 
86
85
  def test_max_with_partial_output_long_lines
87
86
  p = Child.build('yes', "nice to meet you", :max => 10_000)
88
- assert_raise MaximumOutputExceeded do
87
+ assert_raises MaximumOutputExceeded do
89
88
  p.exec!
90
89
  end
91
90
  assert_output_exceeds_repeated_string("nice to meet you\n", 10_000, p.out)
@@ -93,14 +92,14 @@ class ChildTest < Test::Unit::TestCase
93
92
 
94
93
  def test_timeout
95
94
  start = Time.now
96
- assert_raise TimeoutExceeded do
95
+ assert_raises TimeoutExceeded do
97
96
  Child.new('sleep', '1', :timeout => 0.05)
98
97
  end
99
98
  assert (Time.now-start) <= 0.2
100
99
  end
101
100
 
102
101
  def test_timeout_with_child_hierarchy
103
- assert_raise TimeoutExceeded do
102
+ assert_raises TimeoutExceeded do
104
103
  Child.new('/bin/sh', '-c', 'sleep 1', :timeout => 0.05)
105
104
  end
106
105
  end
@@ -108,7 +107,7 @@ class ChildTest < Test::Unit::TestCase
108
107
  def test_timeout_with_partial_output
109
108
  start = Time.now
110
109
  p = Child.build('echo Hello; sleep 1', :timeout => 0.05)
111
- assert_raise TimeoutExceeded do
110
+ assert_raises TimeoutExceeded do
112
111
  p.exec!
113
112
  end
114
113
  assert (Time.now-start) <= 0.2
@@ -0,0 +1,9 @@
1
+ require 'minitest/autorun'
2
+ require 'posix-spawn'
3
+
4
+ if Minitest.const_defined?('Test')
5
+ # We're on Minitest 5+. Nothing to do here.
6
+ else
7
+ # Minitest 4 doesn't have Minitest::Test yet.
8
+ Minitest::Test = MiniTest::Unit::TestCase
9
+ end
@@ -1,7 +1,6 @@
1
- require 'test/unit'
2
- require 'posix-spawn'
1
+ require 'test_helper'
3
2
 
4
- class PopenTest < Test::Unit::TestCase
3
+ class PopenTest < Minitest::Test
5
4
  include POSIX::Spawn
6
5
 
7
6
  def test_popen4
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'posix-spawn'
1
+ require 'test_helper'
3
2
 
4
3
  module SpawnImplementationTests
5
4
  def test_spawn_simple
@@ -23,7 +22,7 @@ module SpawnImplementationTests
23
22
  end
24
23
 
25
24
  def test_spawn_with_invalid_argv
26
- assert_raise ArgumentError do
25
+ assert_raises ArgumentError do
27
26
  _spawn(['echo','b','c','d'])
28
27
  end
29
28
  end
@@ -314,7 +313,7 @@ module SpawnImplementationTests
314
313
  def test_spawn_raises_exception_on_unsupported_options
315
314
  exception = nil
316
315
 
317
- assert_raise ArgumentError do
316
+ assert_raises ArgumentError do
318
317
  begin
319
318
  _spawn('echo howdy', :out => '/dev/null', :oops => 'blaahh')
320
319
  rescue Exception => e
@@ -341,7 +340,7 @@ module SpawnImplementationTests
341
340
  end
342
341
  end
343
342
 
344
- class SpawnTest < Test::Unit::TestCase
343
+ class SpawnTest < Minitest::Test
345
344
  include POSIX::Spawn
346
345
 
347
346
  def test_spawn_methods_exposed_at_module_level
@@ -375,14 +374,14 @@ class SpawnTest < Test::Unit::TestCase
375
374
  end
376
375
  end
377
376
 
378
- class PosixSpawnTest < Test::Unit::TestCase
377
+ class PosixSpawnTest < Minitest::Test
379
378
  include SpawnImplementationTests
380
379
  def _spawn(*argv)
381
380
  POSIX::Spawn.pspawn(*argv)
382
381
  end
383
382
  end
384
383
 
385
- class ForkSpawnTest < Test::Unit::TestCase
384
+ class ForkSpawnTest < Minitest::Test
386
385
  include SpawnImplementationTests
387
386
  def _spawn(*argv)
388
387
  POSIX::Spawn.fspawn(*argv)
@@ -390,7 +389,7 @@ class ForkSpawnTest < Test::Unit::TestCase
390
389
  end
391
390
 
392
391
  if ::Process::respond_to?(:spawn)
393
- class NativeSpawnTest < Test::Unit::TestCase
392
+ class NativeSpawnTest < Minitest::Test
394
393
  include SpawnImplementationTests
395
394
  def _spawn(*argv)
396
395
  ::Process.spawn(*argv)
@@ -1,7 +1,6 @@
1
- require 'test/unit'
2
- require 'posix-spawn'
1
+ require 'test_helper'
3
2
 
4
- class SystemTest < Test::Unit::TestCase
3
+ class SystemTest < Minitest::Test
5
4
  include POSIX::Spawn
6
5
 
7
6
  def test_system
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-spawn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-01 00:00:00.000000000 Z
12
+ date: 2015-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.7.6
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '4'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '4'
28
42
  description: posix-spawn uses posix_spawnp(2) for faster process spawning
29
43
  email:
30
44
  - r@tomayko.com
@@ -54,12 +68,14 @@ files:
54
68
  - posix-spawn.gemspec
55
69
  - test/test_backtick.rb
56
70
  - test/test_child.rb
71
+ - test/test_helper.rb
57
72
  - test/test_popen.rb
58
73
  - test/test_spawn.rb
59
74
  - test/test_system.rb
60
- homepage: http://github.com/rtomayko/posix-spawn
75
+ homepage: https://github.com/rtomayko/posix-spawn
61
76
  licenses:
62
77
  - MIT
78
+ - LGPL
63
79
  metadata: {}
64
80
  post_install_message:
65
81
  rdoc_options: []