cmd-utils 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test-lookup.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  # test-cmd-utils.rb -- simple tester for cmd-utils
3
3
  #
4
+ $:.unshift '.', 'lib'
5
+
4
6
  require 'rubygems'
5
- gem 'minitest'
6
- require 'minitest/autorun'
7
+ require 'helper'
8
+
7
9
  require 'lookup'
8
10
 
9
11
  class NilClass ; def to_s ; '' ; end ; end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # test-run-utils.rb -- simple tester for cmd-utils
3
+
4
+ $:.unshift '.', 'lib', '../lib'
5
+
6
+ require 'rubygems'
7
+ require 'helper'
8
+
9
+ require 'run-utils'
10
+
11
+ # these routines produce output on STDERR depending on $norun, $verbose, and $quiet.
12
+
13
+ class TestRunUtils < Minitest::Test
14
+
15
+ include Run_Test
16
+
17
+ def test_run_output
18
+ run_test("run 1", 'n', false, "(norun) echo 'hello'\n") { cmd_run "echo 'hello'" }
19
+ run_test("run 2", 'v', "hello\n", ">> echo 'hello'\n") { cmd_run "echo 'hello'" }
20
+ run_test("run 3", '', "hello\n", false) { cmd_run "echo 'hello'" }
21
+ run_test("run 4", '', false, "hello\n") { cmd_run "echo 'hello' 1>&2" }
22
+ run_test("run 5", '', false, false) { cmd_run "echo" }
23
+ end
24
+
25
+ def test_run_errmsg
26
+ run_test("run 11", 'n', false, "(norun) ( exit 1)\n") { cmd_run "( exit 1)", 'error 11' }
27
+ run_test("run 12", 'v', false, ">> ( exit 1)\nerror 12\n") { cmd_run "( exit 1)", 'error 12' }
28
+ run_test("run 13", 'v', false, ">> ( exit 0)\n") { cmd_run "( exit 0)", 'no error 13' }
29
+ run_test("run 14", ' ', false, false) { cmd_run "( exit 0)", 'no error 13' }
30
+ end
31
+ end
@@ -1,55 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
- # test-cmd-utils.rb -- simple tester for cmd-utils
2
+ # test-talk-utils.rb -- simple tester for cmd-utils
3
3
  #
4
+ $:.unshift '.', 'lib', '../lib'
4
5
  require 'rubygems'
5
- #require 'minitest'
6
- require 'minitest/autorun'
7
- require 'cmd-utils'
6
+ require 'helper'
7
+
8
+ require 'talk-utils'
8
9
 
9
10
  # these routines produce output on STDERR depending on $norun, $verbose, and $quiet.
10
11
 
11
- class TestCmdUtils < Minitest::Test
12
+ class TestTalkUtils < Minitest::Test
12
13
 
13
- #def gen_test name, norun, verbose, quiet, debug, output
14
- def gen_test name, flags, output
15
- $norun = flags.include?('n')
16
- $verbose = flags.include?('v')
17
- $quiet = flags.include?('q')
18
- $debug = flags.include?('d')
19
- out, err = capture_io { yield }
20
- assert_empty(out, "#{name} $stdout should be empty")
21
- io_assert :stderr, name, err, output
22
- end
23
-
24
- def run_test name, flags, output=nil, errput=nil
25
- $norun = flags.include?('n')
26
- $verbose = flags.include?('v')
27
- $quiet = flags.include?('q')
28
- $debug = flags.include?('d')
29
- begin
30
- out, err = capture_subprocess_io do
31
- begin
32
- yield
33
- rescue
34
- end
35
- end
36
- rescue
37
- end
38
- io_assert :stdout, name, out, output
39
- io_assert :stderr, name, err, errput
40
- true
41
- end
42
-
43
- def io_assert ioname, name, actual, expected
44
- if expected
45
- case expected
46
- when TrueClass then refute_empty(actual, "#{name} $#{ioname} should not be empty")
47
- when FalseClass then assert_empty(actual, "#{name} $#{ioname} should be empty")
48
- when String then assert_match(actual, expected, "#{name} $#{ioname}: expected '#{expected}', got: '#{actual}'")
49
- end
50
- end
51
- true
52
- end
14
+ include Gen_Test
53
15
 
54
16
  def test_talk_arg
55
17
  gen_test('talk_arg', ' ', true) { talk "hello" }
@@ -294,18 +256,5 @@ class TestCmdUtils < Minitest::Test
294
256
  gen_test('talkf_default_content', ' ', "-hello-there-") { talkf { [ "-%s-%s-", "hello", "there" ] } }
295
257
  end
296
258
 
297
- def test_run_output
298
- run_test("run 1", 'n', false, "(norun) echo 'hello'\n") { cmd_run "echo 'hello'" }
299
- run_test("run 2", 'v', "hello\n", ">> echo 'hello'\n") { cmd_run "echo 'hello'" }
300
- run_test("run 3", '', "hello\n", false) { cmd_run "echo 'hello'" }
301
- run_test("run 4", '', false, "hello\n") { cmd_run "echo 'hello' 1>&2" }
302
- run_test("run 5", '', false, false) { cmd_run "echo" }
303
- end
304
-
305
- def test_run_errmsg
306
- run_test("run 11", 'n', false, "(norun) ( exit 1)\n") { cmd_run "( exit 1)", 'error 11' }
307
- run_test("run 12", 'v', false, ">> ( exit 1)\nerror 12\n") { cmd_run "( exit 1)", 'error 12' }
308
- run_test("run 13", 'v', false, ">> ( exit 0)\n") { cmd_run "( exit 0)", 'no error 13' }
309
- run_test("run 14", ' ', false, false) { cmd_run "( exit 0)", 'no error 13' }
310
- end
311
259
  end
260
+ # end of test-talk-utils.rb
metadata CHANGED
@@ -1,85 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan K. Stebbens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.3.0
19
+ version: '5.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.3.0
26
+ version: '5.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '4.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '4.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version: '2.0'
83
69
  description: Several ruby libraries for building command-line utilities.
84
70
  email: aks@stebbens.org
85
71
  executables: []
@@ -96,13 +82,17 @@ files:
96
82
  - Rakefile
97
83
  - VERSION
98
84
  - cmd-utils.gemspec
85
+ - lib/arg-utils.rb
99
86
  - lib/cmd-utils.rb
87
+ - lib/error-utils.rb
100
88
  - lib/lookup.rb
89
+ - lib/run-utils.rb
101
90
  - lib/ssh-utils.rb
91
+ - lib/talk-utils.rb
102
92
  - test/helper.rb
103
- - test/test-cmd-utils.rb
104
93
  - test/test-lookup.rb
105
- - test/test_cmd-utils.rb.off
94
+ - test/test-run-utils.rb
95
+ - test/test-talk-utils.rb
106
96
  homepage: http://bitbucket.org/aks_/cmd-utils
107
97
  licenses:
108
98
  - MIT
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCmdUtils < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end