execute_shell 0.0.5 → 1.0.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.
@@ -1,127 +0,0 @@
1
- #--
2
- ################################################################################
3
- # Copyright (C) 2011 Travis Herrick #
4
- ################################################################################
5
- # #
6
- # \v^V,^!v\^/ #
7
- # ~% %~ #
8
- # { _ _ } #
9
- # ( * - ) #
10
- # | / | #
11
- # \ _, / #
12
- # \__.__/ #
13
- # #
14
- ################################################################################
15
- # This program is free software: you can redistribute it #
16
- # and/or modify it under the terms of the GNU General Public License #
17
- # as published by the Free Software Foundation, #
18
- # either version 3 of the License, or (at your option) any later version. #
19
- # #
20
- # Commercial licensing may be available for a fee under a different license. #
21
- ################################################################################
22
- # This program is distributed in the hope that it will be useful, #
23
- # but WITHOUT ANY WARRANTY; #
24
- # without even the implied warranty of MERCHANTABILITY #
25
- # or FITNESS FOR A PARTICULAR PURPOSE. #
26
- # See the GNU General Public License for more details. #
27
- # #
28
- # You should have received a copy of the GNU General Public License #
29
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
30
- ################################################################################
31
- #++
32
-
33
- require File.join(File.dirname(File.expand_path(__FILE__)), 'require')
34
-
35
- class ExecuteShellTest < Test::Unit::TestCase
36
- def setup
37
- @class = ExecuteShell
38
- @obj = Object.new
39
- @obj.extend(@class)
40
-
41
- @working_path = Dir.getwd
42
- @home_path = File.expand_path(File.join('~', '..'))
43
- @user = File.basename(File.expand_path('~'))
44
-
45
- Dir.chdir @home_path
46
-
47
- # Setting $stderr to STDERR does not work due to the way
48
- # STDERR was being redirected (or something).
49
- @stdout_inspect = $stdout.inspect
50
- @stderr_inspect = $stderr.inspect
51
- end
52
-
53
- def teardown
54
- Dir.chdir @working_path
55
- assert_equal(@stdout_inspect, $stdout.inspect)
56
- assert_equal(@stderr_inspect, $stderr.inspect)
57
- end
58
-
59
- def test_stdout
60
- command = nil
61
-
62
- case Platform::IMPL
63
- when :linux
64
- command = "ls #{@home_path}"
65
- when :mingw
66
- command = "dir #{convert_to_backslash(@home_path)}"
67
- else
68
- raise_not_implemented
69
- end
70
-
71
- success, output = @obj.shell(command)
72
-
73
- assert output.index(@user),
74
- "'#{command}' does not appear to include " +
75
- "the current user's folder (#{@user})."
76
- assert success, "#{command} was not successful"
77
- end
78
-
79
- def test_stderr
80
- command = nil
81
- result = nil
82
-
83
- folder = 'giggidygiggidy'
84
-
85
- test_path = File.join(@home_path, folder)
86
-
87
- case Platform::IMPL
88
- when :linux
89
- command = "ls #{test_path}"
90
- result = "ls: cannot access #{test_path}: No such file or directory"
91
- when :mingw
92
- command = "dir #{convert_to_backslash(test_path)}"
93
- result = 'File Not Found'
94
- else
95
- raise_not_implemented
96
- end
97
-
98
- success, output = @obj.shell(command)
99
-
100
- assert_equal result, output if Platform::IMPL == :linux
101
-
102
- assert output.index(result)
103
- assert !success
104
- end
105
-
106
- def test_grep
107
- Dir.chdir @working_path
108
- command = 'grep jabberwocky' + 'riseagain * -ri'
109
- result = nil
110
-
111
- assert_equal [true, ''], @obj.shell(command)
112
- end
113
-
114
- ############################################################################
115
- private
116
- ############################################################################
117
-
118
- def convert_to_backslash(text)
119
- text.gsub(%r[/], "\\")
120
- end
121
-
122
- def raise_not_implemented(method)
123
- raise NotImplementedError,
124
- "#{method} " +
125
- "has not been implemented for #{Platform::IMPL}."
126
- end
127
- end
data/test/require.rb DELETED
@@ -1,7 +0,0 @@
1
- root_path = File.join(File.dirname(File.expand_path(__FILE__)), '..')
2
- root_path = File.expand_path(root_path)
3
-
4
- Bundler.require :test
5
- require 'test/unit'
6
-
7
- require_relative '../lib/execute_shell'