spline 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/bin/spline +11 -9
  3. data/lib/spline/version.rb +1 -1
  4. data/lib/spline.rb +1 -8
  5. data/vendor/bundle/ruby/2.1.0/bin/rake +23 -0
  6. data/vendor/bundle/ruby/2.1.0/bin/spline +23 -0
  7. data/vendor/bundle/ruby/2.1.0/build_info/rake-10.3.2.info +1 -0
  8. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/.autotest +7 -0
  9. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/.gemtest +0 -0
  10. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/.rubocop.yml +27 -0
  11. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/.togglerc +7 -0
  12. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/CONTRIBUTING.rdoc +34 -0
  13. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/History.rdoc +609 -0
  14. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/MIT-LICENSE +21 -0
  15. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/Manifest.txt +162 -0
  16. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/README.rdoc +137 -0
  17. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/Rakefile +81 -0
  18. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/bin/rake +33 -0
  19. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/alt_system.rb +110 -0
  20. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/application.rb +783 -0
  21. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/backtrace.rb +23 -0
  22. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/clean.rb +76 -0
  23. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/cloneable.rb +16 -0
  24. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/.document +0 -0
  25. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/compositepublisher.rb +21 -0
  26. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/ftptools.rb +137 -0
  27. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/publisher.rb +81 -0
  28. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  29. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/sshpublisher.rb +61 -0
  30. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/contrib/sys.rb +4 -0
  31. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/cpu_counter.rb +109 -0
  32. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/default_loader.rb +14 -0
  33. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/dsl_definition.rb +198 -0
  34. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/early_time.rb +21 -0
  35. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/core.rb +25 -0
  36. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/module.rb +1 -0
  37. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/string.rb +173 -0
  38. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ext/time.rb +15 -0
  39. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_creation_task.rb +24 -0
  40. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_list.rb +414 -0
  41. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_task.rb +46 -0
  42. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_utils.rb +116 -0
  43. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/file_utils_ext.rb +144 -0
  44. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/gempackagetask.rb +4 -0
  45. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_chain.rb +56 -0
  46. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/invocation_exception_mixin.rb +16 -0
  47. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/linked_list.rb +103 -0
  48. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/loaders/makefile.rb +40 -0
  49. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/multi_task.rb +13 -0
  50. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/name_space.rb +38 -0
  51. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/packagetask.rb +202 -0
  52. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/pathmap.rb +3 -0
  53. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/phony.rb +15 -0
  54. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/private_reader.rb +20 -0
  55. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/promise.rb +99 -0
  56. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/pseudo_status.rb +29 -0
  57. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb +38 -0
  58. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb +22 -0
  59. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rdoctask.rb +4 -0
  60. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/ruby182_test_unit_fix.rb +29 -0
  61. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/rule_recursion_overflow_error.rb +20 -0
  62. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/runtest.rb +27 -0
  63. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/scope.rb +42 -0
  64. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task.rb +383 -0
  65. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_argument_error.rb +7 -0
  66. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_arguments.rb +98 -0
  67. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/task_manager.rb +310 -0
  68. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/tasklib.rb +24 -0
  69. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/testtask.rb +212 -0
  70. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/thread_history_display.rb +48 -0
  71. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/thread_pool.rb +164 -0
  72. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/trace_output.rb +22 -0
  73. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/version.rb +7 -0
  74. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake/win32.rb +56 -0
  75. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/lib/rake.rb +78 -0
  76. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/rakelib/publish.rake +20 -0
  77. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/rakelib/test_times.rake +25 -0
  78. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/file_creation.rb +34 -0
  79. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/helper.rb +127 -0
  80. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/support/rakefile_definitions.rb +478 -0
  81. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/support/ruby_runner.rb +33 -0
  82. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_private_reader.rb +42 -0
  83. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake.rb +40 -0
  84. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_application.rb +641 -0
  85. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_application_options.rb +466 -0
  86. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_backtrace.rb +119 -0
  87. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb +55 -0
  88. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_cpu_counter.rb +50 -0
  89. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_definitions.rb +79 -0
  90. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_directory_task.rb +63 -0
  91. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_dsl.rb +40 -0
  92. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_early_time.rb +31 -0
  93. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_extension.rb +59 -0
  94. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_creation_task.rb +56 -0
  95. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_list.rb +627 -0
  96. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_list_path_map.rb +8 -0
  97. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_task.rb +186 -0
  98. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_file_utils.rb +309 -0
  99. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_ftp_file.rb +74 -0
  100. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_functional.rb +482 -0
  101. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_invocation_chain.rb +64 -0
  102. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_linked_list.rb +84 -0
  103. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_makefile_loader.rb +46 -0
  104. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_multi_task.rb +58 -0
  105. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_name_space.rb +57 -0
  106. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_package_task.rb +79 -0
  107. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map.rb +168 -0
  108. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map_explode.rb +34 -0
  109. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_path_map_partial.rb +18 -0
  110. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_pseudo_status.rb +21 -0
  111. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_rake_test_loader.rb +20 -0
  112. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_reduce_compat.rb +26 -0
  113. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_require.rb +40 -0
  114. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_rules.rb +388 -0
  115. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_scope.rb +44 -0
  116. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task.rb +392 -0
  117. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_argument_parsing.rb +109 -0
  118. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_arguments.rb +127 -0
  119. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_lib.rb +9 -0
  120. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_manager.rb +178 -0
  121. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_manager_argument_resolution.rb +19 -0
  122. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_task_with_arguments.rb +171 -0
  123. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_test_task.rb +141 -0
  124. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_thread_pool.rb +142 -0
  125. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_top_level_functions.rb +71 -0
  126. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_win32.rb +72 -0
  127. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_thread_history_display.rb +101 -0
  128. data/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_trace_output.rb +52 -0
  129. data/vendor/bundle/ruby/2.1.0/specifications/rake-10.3.2.gemspec +45 -0
  130. metadata +127 -2
@@ -0,0 +1,641 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeApplication < Rake::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @app = Rake.application
9
+ @app.options.rakelib = []
10
+ end
11
+
12
+ def setup_command_line(*options)
13
+ ARGV.clear
14
+ options.each do |option|
15
+ ARGV << option
16
+ end
17
+ end
18
+
19
+ def test_display_exception_details
20
+ begin
21
+ raise 'test'
22
+ rescue => ex
23
+ end
24
+
25
+ out, err = capture_io do
26
+ @app.display_error_message ex
27
+ end
28
+
29
+ assert_empty out
30
+
31
+ assert_match 'rake aborted!', err
32
+ assert_match __method__.to_s, err
33
+ end
34
+
35
+ def test_display_exception_details_cause
36
+ skip 'Exception#cause not implemented' unless
37
+ Exception.method_defined? :cause
38
+
39
+ begin
40
+ raise 'cause a'
41
+ rescue
42
+ begin
43
+ raise 'cause b'
44
+ rescue => ex
45
+ end
46
+ end
47
+
48
+ out, err = capture_io do
49
+ @app.display_error_message ex
50
+ end
51
+
52
+ assert_empty out
53
+
54
+ assert_match 'cause a', err
55
+ assert_match 'cause b', err
56
+ end
57
+
58
+ def test_display_exception_details_cause_loop
59
+ skip 'Exception#cause not implemented' unless
60
+ Exception.method_defined? :cause
61
+
62
+ begin
63
+ begin
64
+ raise 'cause a'
65
+ rescue => a
66
+ begin
67
+ raise 'cause b'
68
+ rescue
69
+ raise a
70
+ end
71
+ end
72
+ rescue => ex
73
+ end
74
+
75
+ out, err = capture_io do
76
+ @app.display_error_message ex
77
+ end
78
+
79
+ assert_empty out
80
+
81
+ assert_match 'cause a', err
82
+ assert_match 'cause b', err
83
+ end
84
+
85
+ def test_display_tasks
86
+ @app.options.show_tasks = :tasks
87
+ @app.options.show_task_pattern = //
88
+ @app.last_description = "COMMENT"
89
+ @app.define_task(Rake::Task, "t")
90
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
91
+ assert_match(/^rake t/, out)
92
+ assert_match(/# COMMENT/, out)
93
+ end
94
+
95
+ def test_display_tasks_with_long_comments
96
+ @app.terminal_columns = 80
97
+ @app.options.show_tasks = :tasks
98
+ @app.options.show_task_pattern = //
99
+ numbers = "1234567890" * 8
100
+ @app.last_description = numbers
101
+ @app.define_task(Rake::Task, "t")
102
+
103
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
104
+
105
+ assert_match(/^rake t/, out)
106
+ assert_match(/# #{numbers[0, 65]}\.\.\./, out)
107
+ end
108
+
109
+ def test_display_tasks_with_task_name_wider_than_tty_display
110
+ @app.terminal_columns = 80
111
+ @app.options.show_tasks = :tasks
112
+ @app.options.show_task_pattern = //
113
+ task_name = "task name" * 80
114
+ @app.last_description = "something short"
115
+ @app.define_task(Rake::Task, task_name)
116
+
117
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
118
+
119
+ # Ensure the entire task name is output and we end up showing no description
120
+ assert_match(/rake #{task_name} # .../, out)
121
+ end
122
+
123
+ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
124
+ @app.options.show_tasks = :tasks
125
+ @app.options.show_task_pattern = //
126
+ @app.tty_output = false
127
+ description = "something short"
128
+ task_name = "task name" * 80
129
+ @app.last_description = "something short"
130
+ @app.define_task(Rake::Task, task_name)
131
+
132
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
133
+
134
+ # Ensure the entire task name is output and we end up showing no description
135
+ assert_match(/rake #{task_name} # #{description}/, out)
136
+ end
137
+
138
+ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
139
+ @app.options.show_tasks = :tasks
140
+ @app.options.show_task_pattern = //
141
+ @app.tty_output = false
142
+ @app.last_description = "1234567890" * 8
143
+ @app.define_task(Rake::Task, "t")
144
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
145
+ assert_match(/^rake t/, out)
146
+ assert_match(/# #{@app.last_description}/, out)
147
+ end
148
+
149
+ def test_truncating_comments_to_a_non_tty
150
+ @app.terminal_columns = 80
151
+ @app.options.show_tasks = :tasks
152
+ @app.options.show_task_pattern = //
153
+ @app.tty_output = false
154
+ numbers = "1234567890" * 8
155
+ @app.last_description = numbers
156
+ @app.define_task(Rake::Task, "t")
157
+
158
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
159
+
160
+ assert_match(/^rake t/, out)
161
+ assert_match(/# #{numbers[0, 65]}\.\.\./, out)
162
+ end
163
+
164
+ def test_describe_tasks
165
+ @app.options.show_tasks = :describe
166
+ @app.options.show_task_pattern = //
167
+ @app.last_description = "COMMENT"
168
+ @app.define_task(Rake::Task, "t")
169
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
170
+ assert_match(/^rake t$/, out)
171
+ assert_match(/^ {4}COMMENT$/, out)
172
+ end
173
+
174
+ def test_show_lines
175
+ @app.options.show_tasks = :lines
176
+ @app.options.show_task_pattern = //
177
+ @app.last_description = "COMMENT"
178
+ @app.define_task(Rake::Task, "t")
179
+ @app['t'].locations << "HERE:1"
180
+ out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
181
+ assert_match(/^rake t +[^:]+:\d+ *$/, out)
182
+ end
183
+
184
+ def test_finding_rakefile
185
+ rakefile_default
186
+
187
+ assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
188
+ end
189
+
190
+ def test_not_finding_rakefile
191
+ @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
192
+ assert(! @app.instance_eval do have_rakefile end)
193
+ assert_nil @app.rakefile
194
+ end
195
+
196
+ def test_load_rakefile
197
+ rakefile_unittest
198
+
199
+ @app.instance_eval do
200
+ handle_options
201
+ options.silent = true
202
+ load_rakefile
203
+ end
204
+
205
+ assert_equal "rakefile", @app.rakefile.downcase
206
+ assert_equal @tempdir, Dir.pwd
207
+ end
208
+
209
+ def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
210
+ rakefile_unittest
211
+
212
+ _, err = capture_io do
213
+ @app.instance_eval do
214
+ # pretend we started from the unittest dir
215
+ @original_dir = File.expand_path(".")
216
+ raw_load_rakefile
217
+ end
218
+ end
219
+
220
+ assert_empty err
221
+ end
222
+
223
+ def test_load_rakefile_from_subdir
224
+ rakefile_unittest
225
+ Dir.chdir 'subdir'
226
+
227
+ @app.instance_eval do
228
+ handle_options
229
+ options.silent = true
230
+ load_rakefile
231
+ end
232
+
233
+ assert_equal "rakefile", @app.rakefile.downcase
234
+ assert_equal @tempdir, Dir.pwd
235
+ end
236
+
237
+ def test_load_rakefile_prints_rakefile_directory_from_subdir
238
+ rakefile_unittest
239
+ Dir.chdir 'subdir'
240
+
241
+ app = Rake::Application.new
242
+ app.options.rakelib = []
243
+
244
+ _, err = capture_io do
245
+ app.instance_eval do
246
+ raw_load_rakefile
247
+ end
248
+ end
249
+
250
+ assert_equal "(in #{@tempdir}\)\n", err
251
+ end
252
+
253
+ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
254
+ rakefile_unittest
255
+ Dir.chdir 'subdir'
256
+
257
+ _, err = capture_io do
258
+ @app.instance_eval do
259
+ handle_options
260
+ options.silent = true
261
+ raw_load_rakefile
262
+ end
263
+ end
264
+
265
+ assert_empty err
266
+ end
267
+
268
+ def test_load_rakefile_not_found
269
+ ARGV.clear
270
+ Dir.chdir @tempdir
271
+ ENV['RAKE_SYSTEM'] = 'not_exist'
272
+
273
+ @app.instance_eval do
274
+ handle_options
275
+ options.silent = true
276
+ end
277
+
278
+
279
+ ex = assert_raises(RuntimeError) do
280
+ @app.instance_eval do
281
+ raw_load_rakefile
282
+ end
283
+ end
284
+
285
+ assert_match(/no rakefile found/i, ex.message)
286
+ end
287
+
288
+ def test_load_from_system_rakefile
289
+ rake_system_dir
290
+
291
+ @app.instance_eval do
292
+ handle_options
293
+ options.silent = true
294
+ options.load_system = true
295
+ options.rakelib = []
296
+ load_rakefile
297
+ end
298
+
299
+ assert_equal @system_dir, @app.system_dir
300
+ assert_nil @app.rakefile
301
+ rescue SystemExit
302
+ flunk 'failed to load rakefile'
303
+ end
304
+
305
+ def test_load_from_calculated_system_rakefile
306
+ rakefile_default
307
+ def @app.standard_system_dir
308
+ "__STD_SYS_DIR__"
309
+ end
310
+
311
+ ENV['RAKE_SYSTEM'] = nil
312
+
313
+ @app.instance_eval do
314
+ handle_options
315
+ options.silent = true
316
+ options.load_system = true
317
+ options.rakelib = []
318
+ load_rakefile
319
+ end
320
+
321
+ assert_equal "__STD_SYS_DIR__", @app.system_dir
322
+ rescue SystemExit
323
+ flunk 'failed to find system rakefile'
324
+ end
325
+
326
+ def test_terminal_columns
327
+ old_rake_columns = ENV['RAKE_COLUMNS']
328
+
329
+ ENV['RAKE_COLUMNS'] = '42'
330
+
331
+ app = Rake::Application.new
332
+
333
+ assert_equal 42, app.terminal_columns
334
+ ensure
335
+ if old_rake_columns
336
+ ENV['RAKE_COLUMNS'].delete
337
+ else
338
+ ENV['RAKE_COLUMNS'] = old_rake_columns
339
+ end
340
+ end
341
+
342
+ def test_windows
343
+ assert ! (@app.windows? && @app.unix?)
344
+ end
345
+
346
+ def test_loading_imports
347
+ loader = util_loader
348
+
349
+ @app.instance_eval do
350
+ add_loader("dummy", loader)
351
+ add_import("x.dummy")
352
+ load_imports
353
+ end
354
+
355
+ # HACK no assertions
356
+ end
357
+
358
+ def test_building_imported_files_on_demand
359
+ loader = util_loader
360
+
361
+ @app.instance_eval do
362
+ intern(Rake::Task, "x.dummy").enhance do loader.make_dummy end
363
+ add_loader("dummy", loader)
364
+ add_import("x.dummy")
365
+ load_imports
366
+ end
367
+
368
+ # HACK no assertions
369
+ end
370
+
371
+ def test_handle_options_should_strip_options_from_argv
372
+ assert !@app.options.trace
373
+
374
+ valid_option = '--trace'
375
+ setup_command_line(valid_option)
376
+
377
+ @app.handle_options
378
+
379
+ assert !ARGV.include?(valid_option)
380
+ assert @app.options.trace
381
+ end
382
+
383
+ def test_handle_options_trace_default_is_stderr
384
+ setup_command_line("--trace")
385
+
386
+ @app.handle_options
387
+
388
+ assert_equal STDERR, @app.options.trace_output
389
+ assert @app.options.trace
390
+ end
391
+
392
+ def test_handle_options_trace_overrides_to_stdout
393
+ setup_command_line("--trace=stdout")
394
+
395
+ @app.handle_options
396
+
397
+ assert_equal STDOUT, @app.options.trace_output
398
+ assert @app.options.trace
399
+ end
400
+
401
+ def test_handle_options_trace_does_not_eat_following_task_names
402
+ assert !@app.options.trace
403
+
404
+ setup_command_line("--trace", "sometask")
405
+
406
+ @app.handle_options
407
+ assert ARGV.include?("sometask")
408
+ assert @app.options.trace
409
+ end
410
+
411
+ def test_good_run
412
+ ran = false
413
+
414
+ ARGV << '--rakelib=""'
415
+
416
+ @app.options.silent = true
417
+
418
+ @app.instance_eval do
419
+ intern(Rake::Task, "default").enhance { ran = true }
420
+ end
421
+
422
+ rakefile_default
423
+
424
+ out, err = capture_io do
425
+ @app.run
426
+ end
427
+
428
+ assert ran
429
+ assert_empty err
430
+ assert_equal "DEFAULT\n", out
431
+ end
432
+
433
+ def test_display_task_run
434
+ ran = false
435
+ setup_command_line('-f', '-s', '--tasks', '--rakelib=""')
436
+ @app.last_description = "COMMENT"
437
+ @app.define_task(Rake::Task, "default")
438
+ out, = capture_io { @app.run }
439
+ assert @app.options.show_tasks
440
+ assert ! ran
441
+ assert_match(/rake default/, out)
442
+ assert_match(/# COMMENT/, out)
443
+ end
444
+
445
+ def test_display_prereqs
446
+ ran = false
447
+ setup_command_line('-f', '-s', '--prereqs', '--rakelib=""')
448
+ @app.last_description = "COMMENT"
449
+ t = @app.define_task(Rake::Task, "default")
450
+ t.enhance([:a, :b])
451
+ @app.define_task(Rake::Task, "a")
452
+ @app.define_task(Rake::Task, "b")
453
+ out, = capture_io { @app.run }
454
+ assert @app.options.show_prereqs
455
+ assert ! ran
456
+ assert_match(/rake a$/, out)
457
+ assert_match(/rake b$/, out)
458
+ assert_match(/rake default\n( *(a|b)\n){2}/m, out)
459
+ end
460
+
461
+ def test_bad_run
462
+ @app.intern(Rake::Task, "default").enhance { fail }
463
+ setup_command_line('-f', '-s', '--rakelib=""')
464
+ _, err = capture_io {
465
+ assert_raises(SystemExit){ @app.run }
466
+ }
467
+ assert_match(/see full trace/i, err)
468
+ ensure
469
+ ARGV.clear
470
+ end
471
+
472
+ def test_bad_run_with_trace
473
+ @app.intern(Rake::Task, "default").enhance { fail }
474
+ setup_command_line('-f', '-s', '-t')
475
+ _, err = capture_io {
476
+ assert_raises(SystemExit) { @app.run }
477
+ }
478
+ refute_match(/see full trace/i, err)
479
+ ensure
480
+ ARGV.clear
481
+ end
482
+
483
+ def test_bad_run_with_backtrace
484
+ @app.intern(Rake::Task, "default").enhance { fail }
485
+ setup_command_line('-f', '-s', '--backtrace')
486
+ _, err = capture_io {
487
+ assert_raises(SystemExit) {
488
+ @app.run
489
+ }
490
+ }
491
+ refute_match(/see full trace/, err)
492
+ ensure
493
+ ARGV.clear
494
+ end
495
+
496
+ CustomError = Class.new(RuntimeError)
497
+
498
+ def test_bad_run_includes_exception_name
499
+ @app.intern(Rake::Task, "default").enhance {
500
+ raise CustomError, "intentional"
501
+ }
502
+ setup_command_line('-f', '-s')
503
+ _, err = capture_io {
504
+ assert_raises(SystemExit) {
505
+ @app.run
506
+ }
507
+ }
508
+ assert_match(/CustomError: intentional/, err)
509
+ end
510
+
511
+ def test_rake_error_excludes_exception_name
512
+ @app.intern(Rake::Task, "default").enhance {
513
+ fail "intentional"
514
+ }
515
+ setup_command_line('-f', '-s')
516
+ _, err = capture_io {
517
+ assert_raises(SystemExit) {
518
+ @app.run
519
+ }
520
+ }
521
+ refute_match(/RuntimeError/, err)
522
+ assert_match(/intentional/, err)
523
+ end
524
+
525
+ def cause_supported?
526
+ ex = StandardError.new
527
+ ex.respond_to?(:cause)
528
+ end
529
+
530
+ def test_printing_original_exception_cause
531
+ custom_error = Class.new(StandardError)
532
+ @app.intern(Rake::Task, "default").enhance {
533
+ begin
534
+ raise custom_error, "Original Error"
535
+ rescue custom_error
536
+ raise custom_error, "Secondary Error"
537
+ end
538
+ }
539
+ setup_command_line('-f', '-s')
540
+ _ ,err = capture_io {
541
+ assert_raises(SystemExit) {
542
+ @app.run
543
+ }
544
+ }
545
+ if cause_supported?
546
+ assert_match(/Original Error/, err)
547
+ end
548
+ assert_match(/Secondary Error/, err)
549
+ ensure
550
+ ARGV.clear
551
+ end
552
+
553
+ def test_run_with_bad_options
554
+ @app.intern(Rake::Task, "default").enhance { fail }
555
+ setup_command_line('-f', '-s', '--xyzzy')
556
+ assert_raises(SystemExit) {
557
+ capture_io { @app.run }
558
+ }
559
+ ensure
560
+ ARGV.clear
561
+ end
562
+
563
+ def test_standard_exception_handling_invalid_option
564
+ out, err = capture_io do
565
+ e = assert_raises SystemExit do
566
+ @app.standard_exception_handling do
567
+ raise OptionParser::InvalidOption, 'blah'
568
+ end
569
+ end
570
+
571
+ assert_equal 1, e.status
572
+ end
573
+
574
+ assert_empty out
575
+ assert_equal "invalid option: blah\n", err
576
+ end
577
+
578
+ def test_standard_exception_handling_other
579
+ out, err = capture_io do
580
+ e = assert_raises SystemExit do
581
+ @app.standard_exception_handling do
582
+ raise 'blah'
583
+ end
584
+ end
585
+
586
+ assert_equal 1, e.status
587
+ end
588
+
589
+ assert_empty out
590
+ assert_match "rake aborted!\n", err
591
+ assert_match "blah\n", err
592
+ end
593
+
594
+ def test_standard_exception_handling_system_exit
595
+ out, err = capture_io do
596
+ e = assert_raises SystemExit do
597
+ @app.standard_exception_handling do
598
+ exit 0
599
+ end
600
+ end
601
+
602
+ assert_equal 0, e.status
603
+ end
604
+
605
+ assert_empty out
606
+ assert_empty err
607
+ end
608
+
609
+ def test_standard_exception_handling_system_exit_nonzero
610
+ out, err = capture_io do
611
+ e = assert_raises SystemExit do
612
+ @app.standard_exception_handling do
613
+ exit 5
614
+ end
615
+ end
616
+
617
+ assert_equal 5, e.status
618
+ end
619
+
620
+ assert_empty out
621
+ assert_empty err
622
+ end
623
+
624
+ def util_loader
625
+ loader = Object.new
626
+
627
+ loader.instance_variable_set :@load_called, false
628
+ def loader.load arg
629
+ raise ArgumentError, arg unless arg == 'x.dummy'
630
+ @load_called = true
631
+ end
632
+
633
+ loader.instance_variable_set :@make_dummy_called, false
634
+ def loader.make_dummy
635
+ @make_dummy_called = true
636
+ end
637
+
638
+ loader
639
+ end
640
+
641
+ end