amp 0.5.2 → 0.5.3

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.
Files changed (232) hide show
  1. data/.gitignore +12 -0
  2. data/.hgignore +3 -0
  3. data/AUTHORS +1 -1
  4. data/Manifest.txt +99 -38
  5. data/README.md +3 -3
  6. data/Rakefile +53 -18
  7. data/SCHEDULE.markdown +5 -1
  8. data/TODO.markdown +120 -149
  9. data/ampfile.rb +3 -1
  10. data/bin/amp +4 -1
  11. data/ext/amp/bz2/extconf.rb +1 -1
  12. data/ext/amp/mercurial_patch/extconf.rb +1 -1
  13. data/ext/amp/mercurial_patch/mpatch.c +4 -3
  14. data/ext/amp/priority_queue/extconf.rb +1 -1
  15. data/ext/amp/support/extconf.rb +1 -1
  16. data/ext/amp/support/support.c +1 -1
  17. data/lib/amp.rb +125 -67
  18. data/lib/amp/commands/command.rb +12 -10
  19. data/lib/amp/commands/command_support.rb +8 -1
  20. data/lib/amp/commands/commands/help.rb +2 -20
  21. data/lib/amp/commands/commands/init.rb +14 -2
  22. data/lib/amp/commands/commands/templates.rb +6 -4
  23. data/lib/amp/commands/commands/version.rb +15 -1
  24. data/lib/amp/commands/commands/workflow.rb +3 -3
  25. data/lib/amp/commands/commands/workflows/git/add.rb +3 -3
  26. data/lib/amp/commands/commands/workflows/git/copy.rb +1 -1
  27. data/lib/amp/commands/commands/workflows/git/rm.rb +4 -2
  28. data/lib/amp/commands/commands/workflows/hg/add.rb +1 -1
  29. data/lib/amp/commands/commands/workflows/hg/addremove.rb +2 -2
  30. data/lib/amp/commands/commands/workflows/hg/annotate.rb +8 -2
  31. data/lib/amp/commands/commands/workflows/hg/bisect.rb +253 -0
  32. data/lib/amp/commands/commands/workflows/hg/branch.rb +1 -1
  33. data/lib/amp/commands/commands/workflows/hg/branches.rb +3 -3
  34. data/lib/amp/commands/commands/workflows/hg/bundle.rb +3 -3
  35. data/lib/amp/commands/commands/workflows/hg/clone.rb +4 -5
  36. data/lib/amp/commands/commands/workflows/hg/commit.rb +37 -1
  37. data/lib/amp/commands/commands/workflows/hg/copy.rb +2 -1
  38. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +1 -1
  39. data/lib/amp/commands/commands/workflows/hg/diff.rb +3 -8
  40. data/lib/amp/commands/commands/workflows/hg/forget.rb +5 -4
  41. data/lib/amp/commands/commands/workflows/hg/identify.rb +6 -6
  42. data/lib/amp/commands/commands/workflows/hg/import.rb +1 -1
  43. data/lib/amp/commands/commands/workflows/hg/incoming.rb +2 -2
  44. data/lib/amp/commands/commands/workflows/hg/log.rb +5 -4
  45. data/lib/amp/commands/commands/workflows/hg/merge.rb +1 -1
  46. data/lib/amp/commands/commands/workflows/hg/move.rb +5 -3
  47. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +1 -1
  48. data/lib/amp/commands/commands/workflows/hg/push.rb +6 -7
  49. data/lib/amp/commands/commands/workflows/hg/remove.rb +2 -2
  50. data/lib/amp/commands/commands/workflows/hg/resolve.rb +6 -23
  51. data/lib/amp/commands/commands/workflows/hg/root.rb +1 -2
  52. data/lib/amp/commands/commands/workflows/hg/status.rb +21 -12
  53. data/lib/amp/commands/commands/workflows/hg/tag.rb +2 -2
  54. data/lib/amp/commands/commands/workflows/hg/untrack.rb +12 -0
  55. data/lib/amp/commands/commands/workflows/hg/verify.rb +13 -3
  56. data/lib/amp/commands/commands/workflows/hg/what_changed.rb +18 -0
  57. data/lib/amp/commands/dispatch.rb +12 -13
  58. data/lib/amp/dependencies/amp_support.rb +1 -1
  59. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +1 -0
  60. data/lib/amp/dependencies/maruku.rb +136 -0
  61. data/lib/amp/dependencies/maruku/attributes.rb +227 -0
  62. data/lib/amp/dependencies/maruku/defaults.rb +71 -0
  63. data/lib/amp/dependencies/maruku/errors_management.rb +92 -0
  64. data/lib/amp/dependencies/maruku/helpers.rb +260 -0
  65. data/lib/amp/dependencies/maruku/input/charsource.rb +326 -0
  66. data/lib/amp/dependencies/maruku/input/extensions.rb +69 -0
  67. data/lib/amp/dependencies/maruku/input/html_helper.rb +189 -0
  68. data/lib/amp/dependencies/maruku/input/linesource.rb +111 -0
  69. data/lib/amp/dependencies/maruku/input/parse_block.rb +615 -0
  70. data/lib/amp/dependencies/maruku/input/parse_doc.rb +234 -0
  71. data/lib/amp/dependencies/maruku/input/parse_span_better.rb +746 -0
  72. data/lib/amp/dependencies/maruku/input/rubypants.rb +225 -0
  73. data/lib/amp/dependencies/maruku/input/type_detection.rb +147 -0
  74. data/lib/amp/dependencies/maruku/input_textile2/t2_parser.rb +163 -0
  75. data/lib/amp/dependencies/maruku/maruku.rb +33 -0
  76. data/lib/amp/dependencies/maruku/output/to_ansi.rb +223 -0
  77. data/lib/amp/dependencies/maruku/output/to_html.rb +991 -0
  78. data/lib/amp/dependencies/maruku/output/to_markdown.rb +164 -0
  79. data/lib/amp/dependencies/maruku/output/to_s.rb +56 -0
  80. data/lib/amp/dependencies/maruku/string_utils.rb +191 -0
  81. data/lib/amp/dependencies/maruku/structures.rb +167 -0
  82. data/lib/amp/dependencies/maruku/structures_inspect.rb +87 -0
  83. data/lib/amp/dependencies/maruku/structures_iterators.rb +61 -0
  84. data/lib/amp/dependencies/maruku/textile2.rb +1 -0
  85. data/lib/amp/dependencies/maruku/toc.rb +199 -0
  86. data/lib/amp/dependencies/maruku/usage/example1.rb +33 -0
  87. data/lib/amp/dependencies/maruku/version.rb +40 -0
  88. data/lib/amp/dependencies/priority_queue.rb +2 -1
  89. data/lib/amp/dependencies/python_config.rb +2 -1
  90. data/lib/amp/graphs/ancestor.rb +2 -1
  91. data/lib/amp/graphs/copies.rb +236 -233
  92. data/lib/amp/help/entries/__default__.erb +31 -0
  93. data/lib/amp/help/entries/commands.erb +6 -0
  94. data/lib/amp/help/entries/mdtest.md +35 -0
  95. data/lib/amp/help/entries/silly +3 -0
  96. data/lib/amp/help/help.rb +288 -0
  97. data/lib/amp/profiling_hacks.rb +5 -3
  98. data/lib/amp/repository/abstract/abstract_changeset.rb +97 -0
  99. data/lib/amp/repository/abstract/abstract_local_repo.rb +181 -0
  100. data/lib/amp/repository/abstract/abstract_staging_area.rb +180 -0
  101. data/lib/amp/repository/abstract/abstract_versioned_file.rb +100 -0
  102. data/lib/amp/repository/abstract/common_methods/changeset.rb +75 -0
  103. data/lib/amp/repository/abstract/common_methods/local_repo.rb +277 -0
  104. data/lib/amp/repository/abstract/common_methods/staging_area.rb +233 -0
  105. data/lib/amp/repository/abstract/common_methods/versioned_file.rb +71 -0
  106. data/lib/amp/repository/generic_repo_picker.rb +78 -0
  107. data/lib/amp/repository/git/repo_format/changeset.rb +336 -0
  108. data/lib/amp/repository/git/repo_format/staging_area.rb +192 -0
  109. data/lib/amp/repository/git/repo_format/versioned_file.rb +119 -0
  110. data/lib/amp/repository/git/repositories/local_repository.rb +164 -0
  111. data/lib/amp/repository/git/repository.rb +41 -0
  112. data/lib/amp/repository/mercurial/encoding/mercurial_diff.rb +382 -0
  113. data/lib/amp/repository/mercurial/encoding/mercurial_patch.rb +1 -0
  114. data/lib/amp/repository/mercurial/encoding/patch.rb +294 -0
  115. data/lib/amp/repository/mercurial/encoding/pure_ruby/ruby_mercurial_patch.rb +124 -0
  116. data/lib/amp/repository/mercurial/merging/merge_ui.rb +327 -0
  117. data/lib/amp/repository/mercurial/merging/simple_merge.rb +452 -0
  118. data/lib/amp/repository/mercurial/repo_format/branch_manager.rb +266 -0
  119. data/lib/amp/repository/mercurial/repo_format/changeset.rb +768 -0
  120. data/lib/amp/repository/mercurial/repo_format/dir_state.rb +716 -0
  121. data/lib/amp/repository/mercurial/repo_format/journal.rb +218 -0
  122. data/lib/amp/repository/mercurial/repo_format/lock.rb +210 -0
  123. data/lib/amp/repository/mercurial/repo_format/merge_state.rb +228 -0
  124. data/lib/amp/repository/mercurial/repo_format/staging_area.rb +367 -0
  125. data/lib/amp/repository/mercurial/repo_format/store.rb +487 -0
  126. data/lib/amp/repository/mercurial/repo_format/tag_manager.rb +322 -0
  127. data/lib/amp/repository/mercurial/repo_format/updatable.rb +543 -0
  128. data/lib/amp/repository/mercurial/repo_format/updater.rb +848 -0
  129. data/lib/amp/repository/mercurial/repo_format/verification.rb +433 -0
  130. data/lib/amp/repository/mercurial/repositories/bundle_repository.rb +216 -0
  131. data/lib/amp/repository/mercurial/repositories/http_repository.rb +386 -0
  132. data/lib/amp/repository/mercurial/repositories/local_repository.rb +2034 -0
  133. data/lib/amp/repository/mercurial/repository.rb +119 -0
  134. data/lib/amp/repository/mercurial/revlogs/bundle_revlogs.rb +249 -0
  135. data/lib/amp/repository/mercurial/revlogs/changegroup.rb +217 -0
  136. data/lib/amp/repository/mercurial/revlogs/changelog.rb +339 -0
  137. data/lib/amp/repository/mercurial/revlogs/file_log.rb +152 -0
  138. data/lib/amp/repository/mercurial/revlogs/index.rb +500 -0
  139. data/lib/amp/repository/mercurial/revlogs/manifest.rb +201 -0
  140. data/lib/amp/repository/mercurial/revlogs/node.rb +20 -0
  141. data/lib/amp/repository/mercurial/revlogs/revlog.rb +1026 -0
  142. data/lib/amp/repository/mercurial/revlogs/revlog_support.rb +129 -0
  143. data/lib/amp/repository/mercurial/revlogs/versioned_file.rb +597 -0
  144. data/lib/amp/repository/repository.rb +11 -88
  145. data/lib/amp/server/extension/amp_extension.rb +3 -3
  146. data/lib/amp/server/fancy_http_server.rb +1 -1
  147. data/lib/amp/server/fancy_views/_browser.haml +1 -1
  148. data/lib/amp/server/fancy_views/_diff_file.haml +1 -8
  149. data/lib/amp/server/fancy_views/changeset.haml +2 -2
  150. data/lib/amp/server/fancy_views/file.haml +1 -1
  151. data/lib/amp/server/fancy_views/file_diff.haml +1 -1
  152. data/lib/amp/support/amp_ui.rb +13 -29
  153. data/lib/amp/support/generator.rb +1 -1
  154. data/lib/amp/support/loaders.rb +1 -2
  155. data/lib/amp/support/logger.rb +10 -16
  156. data/lib/amp/support/match.rb +18 -4
  157. data/lib/amp/support/mercurial/ignore.rb +151 -0
  158. data/lib/amp/support/openers.rb +8 -3
  159. data/lib/amp/support/support.rb +91 -46
  160. data/lib/amp/templates/{blank.commit.erb → mercurial/blank.commit.erb} +0 -0
  161. data/lib/amp/templates/{blank.log.erb → mercurial/blank.log.erb} +0 -0
  162. data/lib/amp/templates/{default.commit.erb → mercurial/default.commit.erb} +0 -0
  163. data/lib/amp/templates/{default.log.erb → mercurial/default.log.erb} +0 -0
  164. data/lib/amp/templates/template.rb +18 -18
  165. data/man/amp.1 +51 -0
  166. data/site/src/about/commands.haml +1 -1
  167. data/site/src/css/amp.css +1 -1
  168. data/site/src/index.haml +3 -3
  169. data/tasks/man.rake +39 -0
  170. data/tasks/stats.rake +1 -10
  171. data/tasks/yard.rake +1 -50
  172. data/test/dirstate_tests/test_dir_state.rb +10 -8
  173. data/test/functional_tests/annotate.out +31 -0
  174. data/test/functional_tests/test_functional.rb +155 -63
  175. data/test/localrepo_tests/ampfile.rb +12 -0
  176. data/test/localrepo_tests/test_local_repo.rb +56 -57
  177. data/test/manifest_tests/test_manifest.rb +3 -5
  178. data/test/merge_tests/test_merge.rb +3 -3
  179. data/test/revlog_tests/test_revlog.rb +14 -6
  180. data/test/store_tests/test_fncache_store.rb +19 -19
  181. data/test/test_19_compatibility.rb +46 -0
  182. data/test/test_base85.rb +2 -2
  183. data/test/test_bdiff.rb +2 -2
  184. data/test/test_changegroup.rb +59 -0
  185. data/test/test_commands.rb +2 -2
  186. data/test/test_difflib.rb +2 -2
  187. data/test/test_generator.rb +34 -0
  188. data/test/test_ignore.rb +203 -0
  189. data/test/test_journal.rb +18 -13
  190. data/test/test_match.rb +2 -2
  191. data/test/test_mdiff.rb +3 -3
  192. data/test/test_mpatch.rb +3 -3
  193. data/test/test_multi_io.rb +40 -0
  194. data/test/test_support.rb +18 -2
  195. data/test/test_templates.rb +38 -0
  196. data/test/test_ui.rb +79 -0
  197. data/test/testutilities.rb +56 -0
  198. metadata +168 -49
  199. data/ext/amp/bz2/mkmf.log +0 -38
  200. data/lib/amp/encoding/mercurial_diff.rb +0 -378
  201. data/lib/amp/encoding/mercurial_patch.rb +0 -1
  202. data/lib/amp/encoding/patch.rb +0 -292
  203. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +0 -123
  204. data/lib/amp/merges/merge_state.rb +0 -164
  205. data/lib/amp/merges/merge_ui.rb +0 -322
  206. data/lib/amp/merges/simple_merge.rb +0 -450
  207. data/lib/amp/repository/branch_manager.rb +0 -234
  208. data/lib/amp/repository/dir_state.rb +0 -950
  209. data/lib/amp/repository/journal.rb +0 -203
  210. data/lib/amp/repository/lock.rb +0 -207
  211. data/lib/amp/repository/repositories/bundle_repository.rb +0 -214
  212. data/lib/amp/repository/repositories/http_repository.rb +0 -377
  213. data/lib/amp/repository/repositories/local_repository.rb +0 -2661
  214. data/lib/amp/repository/store.rb +0 -485
  215. data/lib/amp/repository/tag_manager.rb +0 -319
  216. data/lib/amp/repository/updatable.rb +0 -532
  217. data/lib/amp/repository/verification.rb +0 -431
  218. data/lib/amp/repository/versioned_file.rb +0 -475
  219. data/lib/amp/revlogs/bundle_revlogs.rb +0 -246
  220. data/lib/amp/revlogs/changegroup.rb +0 -217
  221. data/lib/amp/revlogs/changelog.rb +0 -338
  222. data/lib/amp/revlogs/changeset.rb +0 -521
  223. data/lib/amp/revlogs/file_log.rb +0 -165
  224. data/lib/amp/revlogs/index.rb +0 -493
  225. data/lib/amp/revlogs/manifest.rb +0 -195
  226. data/lib/amp/revlogs/node.rb +0 -18
  227. data/lib/amp/revlogs/revlog.rb +0 -1045
  228. data/lib/amp/revlogs/revlog_support.rb +0 -126
  229. data/lib/amp/support/ignore.rb +0 -144
  230. data/site/Rakefile +0 -38
  231. data/test/test_amp.rb +0 -9
  232. data/test/test_helper.rb +0 -15
@@ -96,7 +96,7 @@
96
96
  end
97
97
  end
98
98
  %p
99
- Last, but not least, we have the #{shellscript "on_run"} method. This is how we declare what <em>happens</em> when our command is run - which is what we really care about! You specify what the command does in #{shellscript "on_run"}'s block, which takes two arguments: #{shellscript "options"} and #{shellscript "args"}. These are, respectively, the command-line options passed in plus amp's additions, and the arguments provided by the user. For example: #{shellscript "amp log --verbose --limit=3 arg1 arg2"} would provide #{shellscript "{:verbose => true, :limit => 3, :repository => #&lt;LocalRepository repo&gt;}"} as #{shellscript "options"} and #{shellscript "[arg1, arg2]"} as #{shellscript "args"}.
99
+ Last, but not least, we have the #{shellscript "on_run"} method. This is how we declare what <em>happens</em> when our command is run - which is what we really care about! You specify what the command does in #{shellscript "on_run"}'s block, which takes two arguments: #{shellscript "options"} and #{shellscript "args"}. These are, respectively, the command-line options passed in plus amp's additions, and the arguments provided by the user. For example: #{shellscript "amp log --verbose --limit=3 arg1 arg2"} would provide #{shellscript "{:verbose => true, :limit => 3, :repository => #&lt;LocalRepository repo&gt;}"} as #{shellscript "options"} and #{shellscript "[\"arg1\", \"arg2\"]"} as #{shellscript "args"}.
100
100
  %p
101
101
  Our command is getting changeset information, so it needs a repository to interact with. Unless told to do otherwise, #{blue_amp} will look for a repository and store it in #{shellscript "options[#{symbol :repository}]"}. This will always be an object of the class #{link_to "http://amp.carboni.ca/docs/Amp/Repositories/LocalRepository.html", "LocalRepository"}.
102
102
  %p
@@ -189,7 +189,7 @@ p, .infopage ul.bullets, .infopage ul.bullets li {
189
189
  margin:3px 3px 3px 30px;
190
190
  }
191
191
 
192
- ul.bullets, ul.bullets li { list-style-type:disc; }
192
+ ul.bullets, ul.bullets li { list-style-type:disc; position:relative;clear:left; }
193
193
 
194
194
  .half-border { border-right: none 1px #ccc; border-bottom: none 1px #ccc; }
195
195
 
@@ -15,7 +15,7 @@
15
15
  .rounded.bigbox.pink
16
16
  %h1#latest-version
17
17
  Get Amp
18
- %span.red-text v0.5.1
18
+ %span.red-text== v#{::Amp::VERSION}
19
19
  %ul{:style => "margin-left:2px;"}
20
20
  %li== 1. Get #{ruby_link}. 2. sudo gem install #{blue_amp} --no-wrappers
21
21
  .floatleft{ :style => "width:100%;padding:10px 0em 6px;" }
@@ -97,10 +97,10 @@
97
97
  %span.shellscript hg clone http://bitbucket.org/carbonica/amp/
98
98
  %li Make your changes
99
99
  %li
100
- %span.shellscript hg diff -r rev1 -r rev2 -U 3 > your.patch
100
+ %span.shellscript hg diff > your.patch
101
101
  %li Create ticket on #{lighthouse_link "Lighthouse, attach your patch"}
102
102
  %li Land one patch, you get commit rights
103
- %p== Want more details? Check out our #{link_to "/contribute/", "contributing page." } Or join us at #{link_to "irc://irc.freenode.net/#amp", "#amp on freenode" }.
103
+ %p== Want more details? Check out our #{link_to "/contribute/", "contributing page." } Or join us at #{link_to "irc://irc.freenode.net/#amp-vcs", "#amp-vcs on freenode" }.
104
104
  = render("include/_footer.haml")
105
105
  :plain
106
106
  <script type="text/javascript">
@@ -0,0 +1,39 @@
1
+ require 'rtfm/tasks'
2
+
3
+ RTFM::ManPage.new("amp", 1) do |page|
4
+ page.summary = "Ruby VCS engine"
5
+
6
+ page.option :verbose, "Enables verbose output for the entire Amp process."
7
+ page.option :d, "Prings a variety of debug information about the arguments and options passed into amp.", :long => :"debug-opts"
8
+ page.option :profile, "Profiles the amp process as it runs the requested command. Deprecated and unwise."
9
+ page.option :R, "The path to the repository to use", :long => "repository", :argument => "repo_dir"
10
+ page.option :"pure-ruby", "Use only pure ruby (no C-extensions)"
11
+ page.option :testing, "Running a test. Don't touch this."
12
+
13
+ page.synopsis do |synopsis|
14
+ synopsis.argument "command"
15
+ end
16
+
17
+ page.description do |description|
18
+ description.body = <<-EOF
19
+ Amp is a revolutionary change in how we approach version control systems. Not only does it re-implement
20
+ Mercurial's core in Ruby, but re-thinks how we interact with version control. It intends to wrap multiple
21
+ VCS systems - git, hg, svn - under the same API, allowing the unique Amp command system to work with all
22
+ repositories in the same manner.
23
+
24
+ Amp currently implements Mercurial and a large subset of the Mercurial command-set.
25
+ EOF
26
+ end
27
+
28
+ page.see_also do |also|
29
+ also.reference "hg", 1
30
+ also.reference "git", 1
31
+ also.reference "ruby", 1
32
+ also.reference "amprc", 5
33
+ end
34
+
35
+ page.authors do |authors|
36
+ authors.add "Michael Edgar", "adgar@carboni.ca"
37
+ authors.add "Ari Brown", "seydar@carboni.ca"
38
+ end
39
+ end
@@ -1,12 +1,3 @@
1
- require 'flay'
2
- require 'flay_task'
3
-
4
-
5
- FlayTask.new(:flay, 400) do |t|
6
- t.dirs = %w(lib/amp)
7
- t.verbose = true
8
- end
9
-
10
1
  desc 'Statistics of Code'
11
2
  task :stats do
12
3
  MINIMUM_LOC = 15
@@ -24,7 +15,7 @@ task :stats do
24
15
  files = FileList['lib/**/*.rb'] +
25
16
  FileList["test/**/*.rb"] +
26
17
  FileList["ext/**/*.c"]
27
-
18
+ files.reject! {|f| f =~ /maruku/ && f !~ /to_ansi/ }
28
19
  puts ScriptLines.headline
29
20
  sum = ScriptLines.new("TOTAL (#{files.size} file#{files.size == 1 ? '' : 's'})")
30
21
 
@@ -35,7 +35,7 @@ end
35
35
  namespace :yard do
36
36
 
37
37
  desc 'Force a rebuild of the documentation'
38
- task :full_doc => [ :todo ] do
38
+ task :full_doc do
39
39
  text_files = ["SCHEDULE.markdown", "AUTHORS", "STYLE", "TODO.markdown", "LICENSE"]
40
40
  options = ["--private", "--protected", "-q", "-r README.md"]
41
41
  ruby_files = ["lib/**/**/**/*.rb", "lib/**/**/*.rb", "lib/**/*.rb", "lib/*.rb"]
@@ -54,55 +54,6 @@ namespace :yard do
54
54
  undocd.zero? ? 0.0 : (undocd / total)
55
55
  end
56
56
 
57
- desc 'Generate a TODO file by searching for @todo tags'
58
- task :todo => [ :doc ] do
59
- File.open("TODO.markdown","w") do |out|
60
- classes = YARD::Registry.all(:class)
61
- classes.each do |klass|
62
- need_todo_section = false
63
- klass_todo = []
64
-
65
- klass.tags.each do |tag|
66
- if tag.tag_name.to_s == "todo"
67
- need_todo_section = true
68
- klass_todo << tag.text
69
- end
70
- end
71
-
72
- method_todo_section = false
73
- method_todos = {}
74
- klass.meths(:inherited => false).each do |meth|
75
- meth.tags.each do |tag|
76
- if tag.tag_name.to_s == "todo"
77
- need_todo_section = true
78
- method_todo_section = true
79
- (method_todos[meth] ||= []) << tag.name # @todo puts info in #name, not #text
80
- end
81
- end
82
- end
83
-
84
- if need_todo_section
85
- klassname = klass.path.gsub(/\_/,"\\_")
86
- out << klassname << "\n"
87
- out << ("=" * klassname.size) << "\n"
88
- klass_todo.each {|todo| out << " - #{todo}\n"}
89
- out << "\n"
90
- method_todos.each do |meth, todos|
91
- methname = meth.path.gsub(/\_/,"\\_")
92
- out << methname << "\n"
93
- out << ("-" * methname.size) << "\n"
94
- todos.each do |todo|
95
- out << " - " << todo << "\n"
96
- end
97
- out << "\n"
98
- end
99
- out << "\n"
100
- end
101
-
102
- end
103
- end
104
- end
105
-
106
57
  # rake yard:search[ranks]
107
58
  desc 'Search the methods for the specified tag'
108
59
  task :search => [ :doc ]
@@ -1,4 +1,4 @@
1
- require "test/unit"
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
3
3
 
4
4
  # easyness
@@ -7,14 +7,14 @@ class String
7
7
  end
8
8
 
9
9
 
10
- class TestDirState < Test::Unit::TestCase
10
+ class TestDirState < AmpTestCase
11
11
 
12
12
  def setup
13
13
  f = File.open File.join(File.dirname(__FILE__), "hgrc")
14
14
  @config = PythonConfig::ConfigParser.new f
15
15
  opener = Amp::Opener.new File.expand_path(File.dirname(__FILE__))
16
16
  opener.default = :open_file
17
- @state = Amp::Repositories::DirState.new File.expand_path(File.dirname(__FILE__)), @config, opener
17
+ @state = Amp::Repositories::Mercurial::DirState.new File.expand_path(File.dirname(__FILE__)), @config, opener
18
18
  @files = []
19
19
  end
20
20
 
@@ -33,17 +33,17 @@ class TestDirState < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test_parents_equals
36
- @state.parents = ["asdfasdf", Amp::RevlogSupport::Node::NULL_ID]
36
+ @state.parents = ["asdfasdf", Amp::Mercurial::RevlogSupport::Node::NULL_ID]
37
37
 
38
- assert_equal ["asdfasdf", Amp::RevlogSupport::Node::NULL_ID], @state.parents
38
+ assert_equal ["asdfasdf", Amp::Mercurial::RevlogSupport::Node::NULL_ID], @state.parents
39
39
 
40
40
  @state.parents = "asdfasdf"
41
41
 
42
- assert_equal ["asdfasdf", Amp::RevlogSupport::Node::NULL_ID], @state.parents
42
+ assert_equal ["asdfasdf", Amp::Mercurial::RevlogSupport::Node::NULL_ID], @state.parents
43
43
  end
44
44
 
45
45
  def test_dirty?
46
- @state.parents = ["asdfasdf", Amp::RevlogSupport::Node::NULL_ID] # something to dirty it up
46
+ @state.parents = ["asdfasdf", Amp::Mercurial::RevlogSupport::Node::NULL_ID] # something to dirty it up
47
47
 
48
48
  assert @state.dirty?
49
49
  end
@@ -96,6 +96,8 @@ class TestDirState < Test::Unit::TestCase
96
96
  # the same quirks
97
97
  def test_remove
98
98
  add_file "monkey" # make sure it's in @files
99
+ # pretend the file is normal
100
+ @state.normal "monkey"
99
101
  @state.remove "monkey"
100
102
 
101
103
  assert @state["monkey"].removed?
@@ -174,7 +176,7 @@ class TestDirState < Test::Unit::TestCase
174
176
 
175
177
  @state.send :read!
176
178
 
177
- assert_equal({"oh_nuit" => Amp::Repositories::DirStateEntry.new(:added, 0, -1, -1)}, @state.files)
179
+ assert_equal({"oh_nuit" => Amp::Repositories::Mercurial::DirStateEntry.new(:added, 0, -1, -1)}, @state.files)
178
180
  assert_equal({}, @state.copy_map)
179
181
  end
180
182
 
@@ -0,0 +1,31 @@
1
+ medgar 2: The Amp Commandments Redux:
2
+ tester 0: 1. Thou shalt not useth the "for...in" syntax.
3
+ tester 0: 2. Thou shalt useth only but 80 columns, for those who useth the lord's
4
+ medgar 2: editors, vim and emacs. (emacs sucks - oh no he didn't)
5
+ tester 0: 3. Thou shalt preface thine variables with _ only when thou needest,
6
+ medgar 2: lest ye face judgement for this most grave sin. (this isn't python.
7
+ medgar 2: no __method__ is necessary!)
8
+ medgar 2: 4. Thine variables should have descriptive names, for thine ruby might
9
+ tester 0: read like the psalms.
10
+ tester 0: 5. Thine variables, longer than 6 letters and composed of two or more
11
+ tester 0: words, shall separate those words with the lord's underscore, so thine
12
+ tester 0: code shall flow like the Nile herself.
13
+ tester 0: 6. Thou shalt rake thine yard frequently, to be sure thine code is
14
+ tester 0: well-documented for thine neighbors.
15
+ tester 0: 7. Thou shalt use alias_method over alias or I shall goeth Chris Brown
16
+ medgar 2: all over thou. (meh we don't need threats in the commandments.)
17
+ tester 0: 8. Thou shalt use parentheses in thine defintions of methods, for the
18
+ medgar 2: consistency of the codes in this repository.
19
+ tester 0: 9. Thine comments shall start, when above thine method definitions, with
20
+ tester 0: 2 (two) hashes, and the information, then, beginning on the line below
21
+ tester 0: it. Thou shalt leave one blank comment line between thine comment info
22
+ tester 0: and thine yard information.
23
+ medgar 2: 10. Thou shalt make great and grand use of the yard extension. It is
24
+ medgar 2: pretty sweet.
25
+ seydar 3: 11. Name thine motherfrakking vari
26
+ seydar 3:
27
+ seydar 3:
28
+ seydar 3: VERSION 3
29
+ seydar 3:
30
+ seydar 3: VERSION 3
31
+ seydar 3: ables motherfrakking descriptively.
@@ -1,13 +1,13 @@
1
- require 'test/unit'
2
- require File.expand_path(File.join(File.dirname(__FILE__), "../test_helper"))
1
+ require 'stringio'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../testutilities')
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), "../../lib/amp"))
4
-
4
+ include Amp::KernelMethods
5
5
  # easyness
6
6
  class String
7
7
  def fun_local; File.join($current_basedir, self); end
8
8
  end
9
9
 
10
- class TestFunctional < Test::Unit::TestCase
10
+ class TestFunctional < AmpTestCase
11
11
 
12
12
  AMP_FILE = (RUBY_VERSION < "1.9") ? "amp" : "amp1.9"
13
13
  AMP_BINARY = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', AMP_FILE))
@@ -27,9 +27,20 @@ class TestFunctional < Test::Unit::TestCase
27
27
  # order is followed. So it all goes in one method. Sorry.
28
28
  def test_init
29
29
 
30
+ require "amp/commands/command.rb"
31
+ require_dir { "amp/commands/*.rb" }
32
+ require_dir { "amp/commands/commands/*.rb" }
33
+
34
+ ENV["HGUSER"] = "tester"
35
+
36
+ assert_command_match(/#{Amp::VERSION_TITLE}/, "version")
37
+ assert_command_match(/#{Amp::VERSION}/, "version")
38
+
39
+
30
40
  # Create the mainline repository! Woo!
31
- run_amp_command "init", "testrepo".fun_local
41
+ amp "init", "testrepo".fun_local
32
42
 
43
+ File.safe_unlink "testrepo/ampfile.rb".fun_local
33
44
  # Make sure we've correctly initialized the repository
34
45
  assert_file 'testrepo'
35
46
  assert_file 'testrepo/.hg'
@@ -115,7 +126,7 @@ class TestFunctional < Test::Unit::TestCase
115
126
  exit_repo
116
127
 
117
128
  # Clone testrepo to create "newrepo".
118
- run_amp_command "clone #{"testrepo".fun_local} #{"newrepo".fun_local}"
129
+ amp "clone", ["testrepo".fun_local,"newrepo".fun_local]
119
130
  # Enter the newrepo repository.
120
131
  enter_repo "newrepo"
121
132
 
@@ -135,9 +146,11 @@ class TestFunctional < Test::Unit::TestCase
135
146
  # Make sure that the custom user is still peachy
136
147
  assert_command_match(/user\: +seydar/, "log", nil, :limit => 1)
137
148
 
138
- # Push upstream to testrepo
139
- run_amp_command "push"
149
+ assert_command_match(/demonic infestation/, amp("outgoing"))
150
+ assert_command_match(/experimental branch/, amp("outgoing"))
140
151
 
152
+ # Push upstream to testrepo
153
+ amp "push"
141
154
  # Switch to testrepo
142
155
  exit_repo
143
156
  enter_repo "testrepo"
@@ -168,7 +181,7 @@ class TestFunctional < Test::Unit::TestCase
168
181
  # the date. So just hand-parse the input string and see if the result is in the changelog.
169
182
  require 'time'
170
183
  t = Time.parse("1/1/2009")
171
- assert_command_match(/#{t.to_s}/, "log -l 1")
184
+ assert_command_match(/#{t.to_s}/, "log", ["-l", "1"])
172
185
 
173
186
  # Over-zealous verification never hurt anyone
174
187
  assert_verify
@@ -180,7 +193,7 @@ class TestFunctional < Test::Unit::TestCase
180
193
  # Pull! wooooo!
181
194
  assert_command_match(/added 1 changesets/, "pull")
182
195
  # Update it
183
- update_result = run_amp_command "update"
196
+ update_result = amp "update"
184
197
  # And check to see if the 2 things we did were both in the update
185
198
  assert_match(/1 files updated/, update_result)
186
199
  assert_match(/1 files removed/, update_result)
@@ -191,12 +204,12 @@ class TestFunctional < Test::Unit::TestCase
191
204
  # ok, so right now, newrepo is the same as testrepo.
192
205
  # now to generate a conflict, so we can test merging. we'll need a second child repo.
193
206
  exit_repo
194
- run_amp_command "clone #{"testrepo".fun_local} #{"conflictrepo".fun_local}"
207
+ amp "clone", ["testrepo".fun_local, "conflictrepo".fun_local]
195
208
 
196
209
  # create one branch in conflictrepo
197
210
  enter_repo "conflictrepo"
198
211
  replace_resources_with_version "version5_1"
199
- run_amp_command "status"
212
+ amp "status"
200
213
  commit :message => "conflict, part 1"
201
214
  exit_repo
202
215
 
@@ -206,17 +219,19 @@ class TestFunctional < Test::Unit::TestCase
206
219
  replace_resources_with_version "version5_2"
207
220
 
208
221
  # test addremove, while we're at it!
209
- addremove_result = run_amp_command "addremove"
222
+ addremove_result = amp "addremove"
210
223
  assert_match(/Adding commands\/newz.rb/, addremove_result)
211
224
  assert_match(/Removing commands\/heads.rb/, addremove_result)
212
- run_amp_command "status"
225
+ amp "status"
213
226
  commit :message => "conflict, part 2"
214
227
 
215
228
  # push our conflicting commit to testrepo from the "newrepo" child.
216
- push_results = run_amp_command "push"
229
+ push_results = amp "push"
230
+ p; puts push_results; p
231
+
217
232
  assert_match(/1 changeset/, push_results)
218
- assert_match(/2 changes/, push_results)
219
- assert_match(/2 files/, push_results)
233
+ assert_match(/3 changes/, push_results)
234
+ assert_match(/3 files/, push_results)
220
235
 
221
236
  exit_repo
222
237
 
@@ -229,12 +244,12 @@ class TestFunctional < Test::Unit::TestCase
229
244
  # pull in newrepo's conflicting commit (it will yell at us for the extra head)
230
245
  assert_command_match(/\+1 heads?/, "pull")
231
246
  # Try to merge the 2 changesets
232
- result = run_amp_command("merge")
247
+ result = amp "merge"
233
248
 
234
249
  # Expected results from the merge
235
250
  assert_match(/1 files? unresolved/, result)
236
251
  assert_match(/1 files? removed/, result)
237
- assert_match(/1 files? updated/, result)
252
+ assert_match(/2 files? updated/, result)
238
253
 
239
254
  # Ok, so we have one file that conflicts: STYLE.txt. We want to keep conflictrepo's
240
255
  # version of the file. So we'll suck out the local portion of the conflicted summary.
@@ -243,7 +258,7 @@ class TestFunctional < Test::Unit::TestCase
243
258
  File.open("STYLE.txt","w") {|f| f.write vers1_groups.first}
244
259
 
245
260
  # mark STYLE.txt as resolved, and make sure it successfully was marked
246
- resolve_result = run_amp_command("resolve", ["--mark", "STYLE.txt"])
261
+ resolve_result = amp("resolve", ["--mark", "STYLE.txt"])
247
262
  assert_match(/STYLE.txt marked/, resolve_result)
248
263
  assert_match(/resolved/, resolve_result)
249
264
 
@@ -251,7 +266,7 @@ class TestFunctional < Test::Unit::TestCase
251
266
  commit :message => "conflict resolved!"
252
267
 
253
268
  # push to testrepo
254
- run_amp_command "push"
269
+ amp "push"
255
270
  assert_verify
256
271
  # make sure we're still intact in conflictrepo
257
272
 
@@ -263,12 +278,12 @@ class TestFunctional < Test::Unit::TestCase
263
278
  assert_verify
264
279
 
265
280
  # Test the copy command
266
- run_amp_command("copy", ["-v", "STYLE.txt", "STYLE_copied.txt"])
281
+ amp("copy", ["-v", "STYLE.txt", "STYLE_copied.txt"])
267
282
  assert_file_has_status "STYLE_copied.txt", :added
268
283
  assert_equal File.read("STYLE.txt"), File.read("STYLE_copied.txt")
269
284
 
270
285
  # Test the move command
271
- run_amp_command("move", ["command.rb", "command_moved.rb"])
286
+ amp("move", ["command.rb", "command_moved.rb"])
272
287
  assert_false File.exist?("command.rb")
273
288
  assert File.exist?("command_moved.rb")
274
289
  assert_file_has_status "command.rb", :removed
@@ -285,16 +300,17 @@ class TestFunctional < Test::Unit::TestCase
285
300
  assert_command_match(/newbranch/, "branch")
286
301
 
287
302
  # Only 1 tag, which is the tip
288
- result = run_amp_command("tags").split("\n")
303
+ result = amp("tags").split("\n")
289
304
  result = result.select {|entry| entry =~ /[0-9a-f]{10}/}
290
305
  assert_equal 1, result.size
291
306
  assert_match(/tip/, result.first)
292
307
 
293
308
  # Tag revision 3 as "noobsauce", by "medgar", with commit message "silly commit!"
294
- run_amp_command("tag", ["noobsauce"], {:rev => 3, :user => "medgar", :message => "silly commit!"})
309
+ amp("tag", ["noobsauce"], {:rev => 3, :user => "medgar", :message => "silly commit!"})
295
310
 
296
311
  # Let's make sure our tag went in smoothly.
297
- result = run_amp_command("tags").split("\n")
312
+ result = amp("tags").split("\n")
313
+
298
314
  result = result.select {|entry| entry =~ /[0-9a-f]{10}/}
299
315
  assert_equal 2, result.size
300
316
 
@@ -310,7 +326,7 @@ class TestFunctional < Test::Unit::TestCase
310
326
  assert_match(/9/, result[tip])
311
327
 
312
328
  # And we should make sure the options were passed into the commit correctly.
313
- head_result = run_amp_command("head")
329
+ head_result = amp("head")
314
330
  assert_match(/medgar/, head_result)
315
331
  assert_match(/silly commit!/, head_result)
316
332
 
@@ -321,26 +337,51 @@ class TestFunctional < Test::Unit::TestCase
321
337
  exit_repo
322
338
  enter_repo 'testrepo'
323
339
 
340
+ assert_equal get_resource("command.rb", "version3"), amp("view", ["command.rb"], :rev => 3)
341
+
342
+ annotate_output = amp("annotate", ["STYLE.txt"], :user => true, :number => true).strip
343
+ correct_annotation = read_supporting_file("annotate.out").strip
344
+ assert_equal correct_annotation, annotate_output
345
+
324
346
  # Create a dummy commit
325
347
  File.open('used_in_bundle', 'w') {|f| f.write "monkay" }
326
- amp "commit", :message => 'monkey'
348
+ amp "commit", [], :message => 'monkey'
327
349
  assert_verify
328
350
 
329
- # Create and compare bundles of ALL revisions
330
- assert_amp_hg_bundle_same 'amp_bundle_all.bundle', :all => true
331
-
332
- # Now go only up to the 3rd revision.
333
- assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :all => true
334
-
335
- # We shall now test types 'none', 'bzip2', and 'gzip'
336
- ['none', 'bzip2', 'gzip'].each do |type|
337
- assert_amp_hg_bundle_same "bundle_up_to_7_with_type_#{type}.bundle",
338
- :rev => 7, :type => type, :all => true
339
- end
340
-
341
- # Test making bundles with --base
342
- assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :base => 2
343
- assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :base => 3
351
+ # test that the commands work if we go into a subdir
352
+ Dir.chdir("commands")
353
+ assert_command_runs "status"
354
+ Dir.chdir("..")
355
+
356
+ assert_command_match(/monkey/, "info", "11")
357
+ assert_command_match(/conflict resolved/, "info", ["11", "8"])
358
+
359
+ assert_command_match(/10/, "identify", [], :rev => "10", :num => true)
360
+
361
+ diff_out = amp("diff", ["command.rb", "--rev", "2", "--rev", "3", "--no-color"])
362
+ assert_match(/\+\s+def silly_namespace\(name\)/, diff_out)
363
+ assert_match(/\-\s+def volt_namespace\(name\)/, diff_out)
364
+
365
+ # needs two args
366
+ assert_command_fails "move", ["STYLE.txt"]
367
+ # last argument must be directory if moving multiple files
368
+ assert_command_fails "move", ["STYLE.txt", "command.rb", "STYLE.txt"]
369
+ assert_command_fails "c"
370
+ # # Create and compare bundles of ALL revisions
371
+ # assert_amp_hg_bundle_same 'bundle_all.bundle', :all => true
372
+ #
373
+ # # Now go only up to the 3rd revision.
374
+ # assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :all => true
375
+ #
376
+ # # We shall now test types 'none', 'bzip2', and 'gzip'
377
+ # ['none', 'bzip2', 'gzip'].each do |type|
378
+ # assert_amp_hg_bundle_same "bundle_up_to_7_with_type_#{type}.bundle",
379
+ # :rev => 7, :type => type, :all => true
380
+ # end
381
+ #
382
+ # # Test making bundles with --base
383
+ # assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :rev => 3, :base => 2
384
+ # assert_amp_hg_bundle_same 'bundle_up_to_3.bundle', :base => 3
344
385
  ensure
345
386
  # cleanup
346
387
  exit_repo
@@ -351,6 +392,15 @@ class TestFunctional < Test::Unit::TestCase
351
392
 
352
393
  private ##################################
353
394
 
395
+ def assert_command_runs(command, args=[], opts = {})
396
+ assert run_amp_command_with_code(command, args, opts)[1]
397
+ end
398
+
399
+ def assert_command_fails(command, args = [], opts = {})
400
+ assert_false run_amp_command_with_code(command, args, opts)[1]
401
+ end
402
+
403
+
354
404
  def assert_amp_hg_bundle_same(fname, opts={})
355
405
  amp "bundle", ["amp_#{fname}"], opts
356
406
  hg "bundle", ["hg_#{fname}"], opts
@@ -369,7 +419,7 @@ class TestFunctional < Test::Unit::TestCase
369
419
  ##
370
420
  #
371
421
  def confirm_head_is_first_commit
372
- heads_result = run_amp_command("heads")
422
+ heads_result = amp("heads")
373
423
  assert_match(/changeset\: +0\:/, heads_result)
374
424
  assert_match(/First commit\./, heads_result)
375
425
  end
@@ -378,14 +428,14 @@ class TestFunctional < Test::Unit::TestCase
378
428
  # Asserts that a) heads returns the most recent revision, b) log -l 1 returns only
379
429
  # one revision.
380
430
  def confirm_head_equals_log_limit_one
381
- assert_equal run_amp_command("heads").strip, run_amp_command("log -l 1").strip
431
+ assert_equal amp("heads").strip, amp("log", ["-l","1"]).strip
382
432
  end
383
433
 
384
434
  ##
385
435
  # Asserts that a) heads returns the most recent revision, b) tip returns the correct
386
436
  # revision.
387
437
  def confirm_head_equals_tip
388
- assert_equal run_amp_command("heads").strip, run_amp_command("tip").strip
438
+ assert_equal amp("heads").strip, amp("tip").strip
389
439
  end
390
440
 
391
441
  ##########################################
@@ -395,17 +445,17 @@ class TestFunctional < Test::Unit::TestCase
395
445
  def add_file_ensure_added(source, dest=source)
396
446
  copy_resource(source, dest)
397
447
  assert_file "#{@current_repo}/#{dest}"
398
- run_amp_command "add", dest
448
+ amp "add", dest
399
449
 
400
450
  assert_file_is_added dest
401
451
  end
402
452
 
403
453
  def remove_file(source)
404
- run_amp_command "remove", source
454
+ amp "remove", source
405
455
  end
406
456
 
407
457
  def assert_files_in_manifest(*files)
408
- manifest_result = run_amp_command("manifest")
458
+ manifest_result = amp("manifest")
409
459
  [*files].each do |file|
410
460
  assert_match(/#{file}/, manifest_result)
411
461
  end
@@ -430,23 +480,23 @@ class TestFunctional < Test::Unit::TestCase
430
480
  end
431
481
 
432
482
  def assert_command_match(regex, command, args=[], opts={})
433
- result = run_amp_command command, args, opts
483
+ result = amp command, args, opts
434
484
  assert_match regex, result
435
485
  end
436
486
 
437
487
  def assert_command_no_match(regex, command, args=[], opts={})
438
- result = run_amp_command command, args, opts
439
- assert_no_match regex, result
488
+ result = amp command, args, opts
489
+ refute_match regex, result
440
490
  end
441
491
 
442
492
  def assert_hg_command_match(regex, command, args=[], opts={})
443
- result = run_hg_command command, args, opts
493
+ result = hg command, args, opts
444
494
  assert_match regex, result
445
495
  end
446
496
 
447
497
  def assert_hg_command_no_match(regex, command, args=[], opts={})
448
- result = run_hg_command command, args, opts
449
- assert_no_match regex, result
498
+ result = hg command, args, opts
499
+ refute_match regex, result
450
500
  end
451
501
 
452
502
  def assert_file_has_status(file, status)
@@ -464,18 +514,23 @@ class TestFunctional < Test::Unit::TestCase
464
514
  when :modified
465
515
  "M"
466
516
  end
467
- status_result = run_amp_command "status", nil, status.to_sym => true, :hg => true, :"no-color" => true
468
- assert_match(/#{stat_letter} #{file}/, status_result)
517
+ result = amp("status", nil, status.to_sym => true, :hg => true, :"no-color" => true)
518
+
519
+ assert_match(/#{stat_letter} #{file}/, result)
469
520
  end
470
521
 
471
522
  def commit(options = {})
472
- run_amp_command "commit", [], options
523
+ amp "commit", [], options
473
524
  end
474
525
 
475
526
  ###########################################
476
527
  # OTHER HELPER METHODS
477
528
  ##########################################
478
529
 
530
+ def read_supporting_file(filename)
531
+ File.read(File.join($current_basedir, filename))
532
+ end
533
+
479
534
  def get_resource(file_name, version="")
480
535
  File.read(File.join($current_basedir, "resources", version, file_name))
481
536
  end
@@ -496,6 +551,10 @@ class TestFunctional < Test::Unit::TestCase
496
551
  end
497
552
 
498
553
  def options_hash_to_string(options = {})
554
+ options_hash_to_array(options).join(" ")
555
+ end
556
+
557
+ def options_hash_to_array(options = {})
499
558
  opt_arr = []
500
559
  options.each do |k, v|
501
560
  case v
@@ -504,10 +563,10 @@ class TestFunctional < Test::Unit::TestCase
504
563
  when TrueClass
505
564
  opt_arr << "--#{k}"
506
565
  else
507
- opt_arr << "--#{k}=\"#{v}\""
566
+ opt_arr << "--#{k}" << v
508
567
  end
509
568
  end
510
- opt_arr.join(" ")
569
+ opt_arr
511
570
  end
512
571
 
513
572
  ##
@@ -531,7 +590,7 @@ class TestFunctional < Test::Unit::TestCase
531
590
  # Executes the given command using the amp binary. Backbone of the functional tests.
532
591
  #
533
592
  # @example
534
- # run_amp_command(:commit, "STYLE.txt", :user => "seydar", :date => "1/1/2001")
593
+ # amp(:commit, "STYLE.txt", :user => "seydar", :date => "1/1/2001")
535
594
  # will run
536
595
  # `amp commit --user="seydar" --date="1/1/2001" STYLE.txt`
537
596
  #
@@ -539,9 +598,42 @@ class TestFunctional < Test::Unit::TestCase
539
598
  # @param [Array<String>] args the arguments to supply to the command.
540
599
  # @param [Hash<#to_s => #to_s>] opts the options to pass to the command, such as :user => "seydar"
541
600
  # for a commit command.
601
+ def run_amp_command_with_code(command, args = [], opts = {})
602
+ out = $stdout
603
+ argv = ARGV.dup
604
+ ARGV.clear.concat([command])
605
+ ARGV.concat([*args]) if args
606
+ ARGV.concat(options_hash_to_array(opts)) if opts
607
+ s = StringIO.new
608
+ $display = true
609
+ $stdout = s
610
+ result = ""
611
+ success = false
612
+ begin
613
+ success = Amp::Dispatch.run
614
+ rescue StandardError => err
615
+ $stdout = out
616
+ message = ["***** Left engine failure *****",
617
+ "***** Ejection system error *****",
618
+ "***** Vaccuum in booster engine *****"
619
+ ][rand(3)]
620
+ Amp::UI.say message
621
+ Amp::UI.say err.to_s
622
+ err.backtrace.each {|e| Amp::UI.say "\tfrom #{e}" }
623
+ raise
624
+ ensure
625
+ ARGV.clear.concat(argv)
626
+ $stdout = out
627
+ result = s.string
628
+ end
629
+
630
+ [result, success]
631
+ end
632
+
542
633
  def run_amp_command(command, args = [], opts = {})
543
- args = [args] unless args.kind_of?(Array)
544
- %x(TESTING='true' && #{AMP_BINARY} #{command} #{options_hash_to_string(opts)} #{args.join(" ")})
634
+ result, success = *run_amp_command_with_code(command, args, opts)
635
+
636
+ result
545
637
  end
546
638
  alias_method :amp, :run_amp_command
547
639