cli_test 1.0.0 → 1.0.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.
@@ -1,3 +1,7 @@
1
+ === 1.0.1 / 2011-07-12
2
+
3
+ * Dump exceptions raised during the CLI run into the STDERR when running in-process
4
+
1
5
  === 1.0.0 / 2011-06-24
2
6
 
3
7
  * 1 major enhancement
@@ -6,7 +6,7 @@ rescue LoadError
6
6
  end
7
7
 
8
8
  class CLITest
9
- VERSION = '1.0.0'
9
+ VERSION = '1.0.1'
10
10
 
11
11
  def initialize(binary_path)
12
12
  @binary_path = File.expand_path(binary_path)
@@ -38,10 +38,14 @@ class CLITest
38
38
  $VERBOSE = false
39
39
 
40
40
  load(@binary_path)
41
-
42
41
  return [0, os.string, es.string]
42
+
43
43
  rescue SystemExit => boom # The binary uses exit(), we use that to preserve the output code
44
44
  return [boom.status, os.string, es.string]
45
+ rescue Exception => e
46
+ es.puts(e.class)
47
+ es.puts(e.exception)
48
+ return [1, os.string, es.string]
45
49
  ensure
46
50
  $VERBOSE = verbosity
47
51
  ARGV.replace(old_argv)
@@ -4,7 +4,6 @@ require "tempfile"
4
4
 
5
5
  class TestCliTest < Test::Unit::TestCase
6
6
  class InProcess < CLITest
7
-
8
7
  def not_unix?
9
8
  true
10
9
  end
@@ -73,6 +72,21 @@ class TestCliTest < Test::Unit::TestCase
73
72
  assert_equal 12, s, "Should pass the proper exit status"
74
73
  end
75
74
 
75
+ def test_cli_captures_exceptions_and_reroutes_them_to_stderr_with_inprocess
76
+ f = make_tempfile
77
+ f.puts('#!/usr/bin/env ruby')
78
+ f.puts("raise 'Disaster strikes!'")
79
+ f.chmod(0x777)
80
+ f.flush
81
+
82
+ @app = InProcess.new(f.path)
83
+ assert_nothing_raised("Raised error should be swallowed into STDERR") do
84
+ s, o, e = @app.run('')
85
+ assert_equal 1, s, "Should have simulated an exit with status 1"
86
+ assert_match /Disaster strikes/, e, "Exception should have been flushed into STDERR"
87
+ end
88
+ end
89
+
76
90
  def test_cli_returns_stderr_with_inprocess
77
91
  f = make_tempfile
78
92
  f.puts('#!/usr/bin/env ruby')
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cli_test
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julik Tarkhanov
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-24 00:00:00 Z
13
+ date: 2011-07-12 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hoe
@@ -18,9 +18,9 @@ dependencies:
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 2.9.4
23
+ version: "2.10"
24
24
  type: :development
25
25
  version_requirements: *id001
26
26
  description: Assists in testing commandline applications (run an application qucikly, read out stderr, stdout and status, check option combinations)