bundler-prehistoric 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +100 -0
  5. data/CHANGELOG.md +1640 -0
  6. data/CONTRIBUTING.md +32 -0
  7. data/DEVELOPMENT.md +117 -0
  8. data/Gemfile +3 -0
  9. data/ISSUES.md +96 -0
  10. data/LICENSE.md +23 -0
  11. data/README.md +46 -0
  12. data/Rakefile +256 -0
  13. data/UPGRADING.md +103 -0
  14. data/bin/bundle +21 -0
  15. data/bin/bundle_ruby +56 -0
  16. data/bin/bundler +21 -0
  17. data/bundler.gemspec +33 -0
  18. data/lib/bundler.rb +442 -0
  19. data/lib/bundler/backports/time.rb +7 -0
  20. data/lib/bundler/capistrano.rb +16 -0
  21. data/lib/bundler/cli.rb +395 -0
  22. data/lib/bundler/cli/binstubs.rb +38 -0
  23. data/lib/bundler/cli/cache.rb +34 -0
  24. data/lib/bundler/cli/check.rb +35 -0
  25. data/lib/bundler/cli/clean.rb +19 -0
  26. data/lib/bundler/cli/common.rb +54 -0
  27. data/lib/bundler/cli/config.rb +84 -0
  28. data/lib/bundler/cli/console.rb +39 -0
  29. data/lib/bundler/cli/exec.rb +37 -0
  30. data/lib/bundler/cli/gem.rb +101 -0
  31. data/lib/bundler/cli/init.rb +33 -0
  32. data/lib/bundler/cli/inject.rb +33 -0
  33. data/lib/bundler/cli/install.rb +133 -0
  34. data/lib/bundler/cli/open.rb +23 -0
  35. data/lib/bundler/cli/outdated.rb +80 -0
  36. data/lib/bundler/cli/package.rb +36 -0
  37. data/lib/bundler/cli/platform.rb +43 -0
  38. data/lib/bundler/cli/show.rb +48 -0
  39. data/lib/bundler/cli/update.rb +73 -0
  40. data/lib/bundler/cli/viz.rb +27 -0
  41. data/lib/bundler/constants.rb +5 -0
  42. data/lib/bundler/current_ruby.rb +155 -0
  43. data/lib/bundler/definition.rb +604 -0
  44. data/lib/bundler/dep_proxy.rb +43 -0
  45. data/lib/bundler/dependency.rb +106 -0
  46. data/lib/bundler/deployment.rb +59 -0
  47. data/lib/bundler/deprecate.rb +15 -0
  48. data/lib/bundler/dsl.rb +305 -0
  49. data/lib/bundler/endpoint_specification.rb +76 -0
  50. data/lib/bundler/env.rb +56 -0
  51. data/lib/bundler/environment.rb +42 -0
  52. data/lib/bundler/fetcher.rb +396 -0
  53. data/lib/bundler/friendly_errors.rb +42 -0
  54. data/lib/bundler/gem_helper.rb +169 -0
  55. data/lib/bundler/gem_helpers.rb +25 -0
  56. data/lib/bundler/gem_installer.rb +9 -0
  57. data/lib/bundler/gem_path_manipulation.rb +8 -0
  58. data/lib/bundler/gem_tasks.rb +2 -0
  59. data/lib/bundler/graph.rb +169 -0
  60. data/lib/bundler/index.rb +184 -0
  61. data/lib/bundler/injector.rb +64 -0
  62. data/lib/bundler/installer.rb +332 -0
  63. data/lib/bundler/lazy_specification.rb +83 -0
  64. data/lib/bundler/lockfile_parser.rb +146 -0
  65. data/lib/bundler/match_platform.rb +13 -0
  66. data/lib/bundler/parallel_workers.rb +18 -0
  67. data/lib/bundler/parallel_workers/thread_worker.rb +30 -0
  68. data/lib/bundler/parallel_workers/unix_worker.rb +101 -0
  69. data/lib/bundler/parallel_workers/worker.rb +69 -0
  70. data/lib/bundler/psyched_yaml.rb +26 -0
  71. data/lib/bundler/remote_specification.rb +57 -0
  72. data/lib/bundler/resolver.rb +534 -0
  73. data/lib/bundler/retry.rb +60 -0
  74. data/lib/bundler/ruby_dsl.rb +11 -0
  75. data/lib/bundler/ruby_version.rb +117 -0
  76. data/lib/bundler/rubygems_ext.rb +171 -0
  77. data/lib/bundler/rubygems_integration.rb +578 -0
  78. data/lib/bundler/runtime.rb +310 -0
  79. data/lib/bundler/settings.rb +176 -0
  80. data/lib/bundler/setup.rb +23 -0
  81. data/lib/bundler/shared_helpers.rb +110 -0
  82. data/lib/bundler/similarity_detector.rb +63 -0
  83. data/lib/bundler/source.rb +29 -0
  84. data/lib/bundler/source/git.rb +289 -0
  85. data/lib/bundler/source/git/git_proxy.rb +158 -0
  86. data/lib/bundler/source/path.rb +225 -0
  87. data/lib/bundler/source/path/installer.rb +38 -0
  88. data/lib/bundler/source/rubygems.rb +334 -0
  89. data/lib/bundler/source/svn.rb +260 -0
  90. data/lib/bundler/source/svn/svn_proxy.rb +110 -0
  91. data/lib/bundler/spec_set.rb +154 -0
  92. data/lib/bundler/ssl_certs/.document +1 -0
  93. data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
  94. data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
  95. data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
  96. data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
  97. data/lib/bundler/ssl_certs/certificate_manager.rb +41 -0
  98. data/lib/bundler/templates/Executable +16 -0
  99. data/lib/bundler/templates/Executable.standalone +12 -0
  100. data/lib/bundler/templates/Gemfile +4 -0
  101. data/lib/bundler/templates/newgem/.travis.yml.tt +3 -0
  102. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  103. data/lib/bundler/templates/newgem/LICENSE.txt.tt +22 -0
  104. data/lib/bundler/templates/newgem/README.md.tt +31 -0
  105. data/lib/bundler/templates/newgem/Rakefile.tt +26 -0
  106. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  107. data/lib/bundler/templates/newgem/consolerc.tt +3 -0
  108. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  109. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  110. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  111. data/lib/bundler/templates/newgem/gitignore.tt +16 -0
  112. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
  113. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  114. data/lib/bundler/templates/newgem/newgem.gemspec.tt +38 -0
  115. data/lib/bundler/templates/newgem/rspec.tt +2 -0
  116. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  117. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  118. data/lib/bundler/templates/newgem/test/minitest_helper.rb.tt +4 -0
  119. data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +11 -0
  120. data/lib/bundler/ui.rb +7 -0
  121. data/lib/bundler/ui/rg_proxy.rb +21 -0
  122. data/lib/bundler/ui/shell.rb +98 -0
  123. data/lib/bundler/ui/silent.rb +44 -0
  124. data/lib/bundler/vendor/.document +0 -0
  125. data/lib/bundler/vendor/net/http/faster.rb +26 -0
  126. data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
  127. data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  128. data/lib/bundler/vendor/thor.rb +480 -0
  129. data/lib/bundler/vendor/thor/actions.rb +319 -0
  130. data/lib/bundler/vendor/thor/actions/create_file.rb +103 -0
  131. data/lib/bundler/vendor/thor/actions/create_link.rb +59 -0
  132. data/lib/bundler/vendor/thor/actions/directory.rb +118 -0
  133. data/lib/bundler/vendor/thor/actions/empty_directory.rb +135 -0
  134. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +316 -0
  135. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +107 -0
  136. data/lib/bundler/vendor/thor/base.rb +656 -0
  137. data/lib/bundler/vendor/thor/command.rb +133 -0
  138. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  139. data/lib/bundler/vendor/thor/core_ext/io_binary_read.rb +10 -0
  140. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +98 -0
  141. data/lib/bundler/vendor/thor/error.rb +32 -0
  142. data/lib/bundler/vendor/thor/group.rb +281 -0
  143. data/lib/bundler/vendor/thor/invocation.rb +173 -0
  144. data/lib/bundler/vendor/thor/line_editor.rb +17 -0
  145. data/lib/bundler/vendor/thor/line_editor/basic.rb +35 -0
  146. data/lib/bundler/vendor/thor/line_editor/readline.rb +88 -0
  147. data/lib/bundler/vendor/thor/parser.rb +4 -0
  148. data/lib/bundler/vendor/thor/parser/argument.rb +73 -0
  149. data/lib/bundler/vendor/thor/parser/arguments.rb +175 -0
  150. data/lib/bundler/vendor/thor/parser/option.rb +121 -0
  151. data/lib/bundler/vendor/thor/parser/options.rb +218 -0
  152. data/lib/bundler/vendor/thor/rake_compat.rb +71 -0
  153. data/lib/bundler/vendor/thor/runner.rb +322 -0
  154. data/lib/bundler/vendor/thor/shell.rb +81 -0
  155. data/lib/bundler/vendor/thor/shell/basic.rb +420 -0
  156. data/lib/bundler/vendor/thor/shell/color.rb +149 -0
  157. data/lib/bundler/vendor/thor/shell/html.rb +126 -0
  158. data/lib/bundler/vendor/thor/util.rb +267 -0
  159. data/lib/bundler/vendor/thor/version.rb +3 -0
  160. data/lib/bundler/vendored_persistent.rb +3 -0
  161. data/lib/bundler/vendored_thor.rb +8 -0
  162. data/lib/bundler/version.rb +6 -0
  163. data/lib/bundler/vlad.rb +11 -0
  164. data/man/bundle-config.ronn +155 -0
  165. data/man/bundle-exec.ronn +136 -0
  166. data/man/bundle-install.ronn +372 -0
  167. data/man/bundle-package.ronn +59 -0
  168. data/man/bundle-platform.ronn +42 -0
  169. data/man/bundle-update.ronn +179 -0
  170. data/man/bundle.ronn +92 -0
  171. data/man/gemfile.5.ronn +369 -0
  172. data/man/index.txt +7 -0
  173. data/spec/bundler/bundler_spec.rb +74 -0
  174. data/spec/bundler/cli_spec.rb +16 -0
  175. data/spec/bundler/definition_spec.rb +21 -0
  176. data/spec/bundler/dsl_spec.rb +108 -0
  177. data/spec/bundler/friendly_errors_spec.rb +13 -0
  178. data/spec/bundler/gem_helper_spec.rb +225 -0
  179. data/spec/bundler/psyched_yaml_spec.rb +8 -0
  180. data/spec/bundler/retry_spec.rb +59 -0
  181. data/spec/bundler/settings_spec.rb +13 -0
  182. data/spec/bundler/source_spec.rb +25 -0
  183. data/spec/cache/gems_spec.rb +316 -0
  184. data/spec/cache/git_spec.rb +188 -0
  185. data/spec/cache/path_spec.rb +121 -0
  186. data/spec/cache/platform_spec.rb +53 -0
  187. data/spec/cache/svn_spec.rb +82 -0
  188. data/spec/commands/binstubs_spec.rb +246 -0
  189. data/spec/commands/check_spec.rb +278 -0
  190. data/spec/commands/clean_spec.rb +652 -0
  191. data/spec/commands/config_spec.rb +227 -0
  192. data/spec/commands/console_spec.rb +102 -0
  193. data/spec/commands/exec_spec.rb +367 -0
  194. data/spec/commands/help_spec.rb +39 -0
  195. data/spec/commands/init_spec.rb +39 -0
  196. data/spec/commands/inject_spec.rb +78 -0
  197. data/spec/commands/licenses_spec.rb +31 -0
  198. data/spec/commands/newgem_spec.rb +451 -0
  199. data/spec/commands/open_spec.rb +80 -0
  200. data/spec/commands/outdated_spec.rb +168 -0
  201. data/spec/commands/package_spec.rb +128 -0
  202. data/spec/commands/show_spec.rb +152 -0
  203. data/spec/install/binstubs_spec.rb +24 -0
  204. data/spec/install/bundler_spec.rb +146 -0
  205. data/spec/install/deploy_spec.rb +237 -0
  206. data/spec/install/gemfile/gemspec_spec.rb +170 -0
  207. data/spec/install/gemfile/git_spec.rb +967 -0
  208. data/spec/install/gemfile/path_spec.rb +480 -0
  209. data/spec/install/gemfile/svn_spec.rb +582 -0
  210. data/spec/install/gemfile_spec.rb +44 -0
  211. data/spec/install/gems/c_ext_spec.rb +48 -0
  212. data/spec/install/gems/dependency_api_spec.rb +580 -0
  213. data/spec/install/gems/env_spec.rb +107 -0
  214. data/spec/install/gems/flex_spec.rb +314 -0
  215. data/spec/install/gems/groups_spec.rb +308 -0
  216. data/spec/install/gems/mirror_spec.rb +39 -0
  217. data/spec/install/gems/platform_spec.rb +221 -0
  218. data/spec/install/gems/post_install_spec.rb +121 -0
  219. data/spec/install/gems/resolving_spec.rb +124 -0
  220. data/spec/install/gems/simple_case_spec.rb +386 -0
  221. data/spec/install/gems/standalone_spec.rb +260 -0
  222. data/spec/install/gems/sudo_spec.rb +136 -0
  223. data/spec/install/gems/win32_spec.rb +26 -0
  224. data/spec/install/gemspecs_spec.rb +50 -0
  225. data/spec/install/path_spec.rb +150 -0
  226. data/spec/install/post_bundle_message_spec.rb +142 -0
  227. data/spec/install/prereleases_spec.rb +43 -0
  228. data/spec/install/security_policy_spec.rb +77 -0
  229. data/spec/install/upgrade_spec.rb +26 -0
  230. data/spec/lock/git_spec.rb +34 -0
  231. data/spec/lock/lockfile_spec.rb +912 -0
  232. data/spec/lock/svn_spec.rb +35 -0
  233. data/spec/other/bundle_ruby_spec.rb +142 -0
  234. data/spec/other/cli_dispatch_spec.rb +21 -0
  235. data/spec/other/ext_spec.rb +60 -0
  236. data/spec/other/platform_spec.rb +1285 -0
  237. data/spec/other/ssl_cert_spec.rb +10 -0
  238. data/spec/quality_spec.rb +88 -0
  239. data/spec/realworld/dependency_api_spec.rb +60 -0
  240. data/spec/realworld/edgecases_spec.rb +177 -0
  241. data/spec/realworld/parallel_spec.rb +69 -0
  242. data/spec/resolver/basic_spec.rb +66 -0
  243. data/spec/resolver/platform_spec.rb +88 -0
  244. data/spec/runtime/executable_spec.rb +149 -0
  245. data/spec/runtime/load_spec.rb +107 -0
  246. data/spec/runtime/platform_spec.rb +90 -0
  247. data/spec/runtime/require_spec.rb +332 -0
  248. data/spec/runtime/setup_spec.rb +856 -0
  249. data/spec/runtime/with_clean_env_spec.rb +91 -0
  250. data/spec/spec_helper.rb +114 -0
  251. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  252. data/spec/support/artifice/endpoint.rb +71 -0
  253. data/spec/support/artifice/endpoint_500.rb +37 -0
  254. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  255. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  256. data/spec/support/artifice/endpoint_creds_diff_host.rb +38 -0
  257. data/spec/support/artifice/endpoint_extra.rb +31 -0
  258. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  259. data/spec/support/artifice/endpoint_fallback.rb +17 -0
  260. data/spec/support/artifice/endpoint_host_redirect.rb +15 -0
  261. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  262. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  263. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +18 -0
  264. data/spec/support/artifice/endpoint_timeout.rb +13 -0
  265. data/spec/support/builders.rb +748 -0
  266. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  267. data/spec/support/fakeweb/windows.rb +23 -0
  268. data/spec/support/hax.rb +22 -0
  269. data/spec/support/helpers.rb +348 -0
  270. data/spec/support/indexes.rb +280 -0
  271. data/spec/support/less_than_proc.rb +14 -0
  272. data/spec/support/matchers.rb +77 -0
  273. data/spec/support/path.rb +81 -0
  274. data/spec/support/permissions.rb +10 -0
  275. data/spec/support/platforms.rb +94 -0
  276. data/spec/support/ruby_ext.rb +20 -0
  277. data/spec/support/rubygems_ext.rb +39 -0
  278. data/spec/support/streams.rb +13 -0
  279. data/spec/support/sudo.rb +16 -0
  280. data/spec/update/gems_spec.rb +201 -0
  281. data/spec/update/git_spec.rb +236 -0
  282. data/spec/update/source_spec.rb +63 -0
  283. data/spec/update/svn_spec.rb +100 -0
  284. metadata +486 -0
@@ -0,0 +1,2 @@
1
+ [{ :dependencies[ [" thin" >= 0["ruby-openid"
2
+ 1.0.0
@@ -0,0 +1,23 @@
1
+ require File.expand_path("../../path.rb", __FILE__)
2
+ include Spec::Path
3
+
4
+ files = [ 'specs.4.8.gz',
5
+ 'prerelease_specs.4.8.gz',
6
+ 'quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz',
7
+ 'gems/rcov-1.0-mswin32.gem' ]
8
+
9
+ # Set up pretend http gem server with FakeWeb
10
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}"
11
+ require 'fakeweb'
12
+
13
+ FakeWeb.allow_net_connect = false
14
+
15
+ files.each do |file|
16
+ FakeWeb.register_uri(:get, "http://localgemserver.test/#{file}",
17
+ :body => File.read("#{gem_repo1}/#{file}"))
18
+ end
19
+ FakeWeb.register_uri(:get, "http://localgemserver.test/gems/rcov-1.0-x86-mswin32.gem",
20
+ :status => ["404", "Not Found"])
21
+
22
+ FakeWeb.register_uri(:get, "http://localgemserver.test/api/v1/dependencies",
23
+ :status => ["404", "Not Found"])
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+
3
+ class Gem::Platform
4
+ @local = new(ENV['BUNDLER_SPEC_PLATFORM']) if ENV['BUNDLER_SPEC_PLATFORM']
5
+ end
6
+
7
+ if ENV['BUNDLER_SPEC_VERSION']
8
+ module Bundler
9
+ VERSION = ENV['BUNDLER_SPEC_VERSION'].dup
10
+ end
11
+ end
12
+
13
+ class Object
14
+ if ENV['BUNDLER_SPEC_RUBY_ENGINE']
15
+ remove_const :RUBY_ENGINE if defined?(RUBY_ENGINE)
16
+ RUBY_ENGINE = ENV['BUNDLER_SPEC_RUBY_ENGINE']
17
+
18
+ if RUBY_ENGINE == "jruby"
19
+ JRUBY_VERSION = ENV["BUNDLER_SPEC_RUBY_ENGINE_VERSION"]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,348 @@
1
+ module Spec
2
+ module Helpers
3
+ def reset!
4
+ @in_p, @out_p, @err_p = nil, nil, nil
5
+ Dir["#{tmp}/{gems/*,*}"].each do |dir|
6
+ next if %(base remote1 gems rubygems).include?(File.basename(dir))
7
+ unless ENV['BUNDLER_SUDO_TESTS']
8
+ FileUtils.rm_rf(dir)
9
+ else
10
+ `sudo rm -rf #{dir}`
11
+ end
12
+ end
13
+ FileUtils.mkdir_p(tmp)
14
+ FileUtils.mkdir_p(home)
15
+ end
16
+
17
+ attr_reader :out, :err, :exitstatus
18
+
19
+ def in_app_root(&blk)
20
+ Dir.chdir(bundled_app, &blk)
21
+ end
22
+
23
+ def in_app_root2(&blk)
24
+ Dir.chdir(bundled_app2, &blk)
25
+ end
26
+
27
+ def in_app_root_custom(root, &blk)
28
+ Dir.chdir(root, &blk)
29
+ end
30
+
31
+ def run(cmd, *args)
32
+ opts = args.last.is_a?(Hash) ? args.pop : {}
33
+ expect_err = opts.delete(:expect_err)
34
+ env = opts.delete(:env)
35
+ groups = args.map {|a| a.inspect }.join(", ")
36
+ setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
37
+ @out = ruby(setup + cmd, :expect_err => expect_err, :env => env)
38
+ end
39
+
40
+ def load_error_run(ruby, name, *args)
41
+ cmd = <<-RUBY
42
+ begin
43
+ #{ruby}
44
+ rescue LoadError => e
45
+ $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("-- #{name}")
46
+ end
47
+ RUBY
48
+ opts = args.last.is_a?(Hash) ? args.pop : {}
49
+ opts.merge!(:expect_err => true)
50
+ args += [opts]
51
+ run(cmd, *args)
52
+ end
53
+
54
+ def lib
55
+ File.expand_path('../../../lib', __FILE__)
56
+ end
57
+
58
+ def bundle(cmd, options = {})
59
+ expect_err = options.delete(:expect_err)
60
+ exitstatus = options.delete(:exitstatus)
61
+ sudo = "sudo" if options.delete(:sudo)
62
+ options["no-color"] = true unless options.key?("no-color") || %w(exec conf).include?(cmd.to_s[0..3])
63
+
64
+ bundle_bin = File.expand_path('../../../bin/bundle', __FILE__)
65
+
66
+ requires = options.delete(:requires) || []
67
+ requires << File.expand_path('../fakeweb/'+options.delete(:fakeweb)+'.rb', __FILE__) if options.key?(:fakeweb)
68
+ requires << File.expand_path('../artifice/'+options.delete(:artifice)+'.rb', __FILE__) if options.key?(:artifice)
69
+ requires_str = requires.map{|r| "-r#{r}"}.join(" ")
70
+
71
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}'"}.join(" ")
72
+ args = options.map do |k,v|
73
+ v == true ? " --#{k}" : " --#{k} #{v}" if v
74
+ end.join
75
+
76
+ cmd = "#{env} #{sudo} #{Gem.ruby} -I#{lib} #{requires_str} #{bundle_bin} #{cmd}#{args}"
77
+
78
+ if exitstatus
79
+ sys_status(cmd)
80
+ else
81
+ sys_exec(cmd, expect_err){|i| yield i if block_given? }
82
+ end
83
+ end
84
+
85
+ def bundle_ruby(options = {})
86
+ expect_err = options.delete(:expect_err)
87
+ exitstatus = options.delete(:exitstatus)
88
+ options["no-color"] = true unless options.key?("no-color")
89
+
90
+ bundle_bin = File.expand_path('../../../bin/bundle_ruby', __FILE__)
91
+
92
+ requires = options.delete(:requires) || []
93
+ requires << File.expand_path('../fakeweb/'+options.delete(:fakeweb)+'.rb', __FILE__) if options.key?(:fakeweb)
94
+ requires << File.expand_path('../artifice/'+options.delete(:artifice)+'.rb', __FILE__) if options.key?(:artifice)
95
+ requires_str = requires.map{|r| "-r#{r}"}.join(" ")
96
+
97
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
98
+ cmd = "#{env}#{Gem.ruby} -I#{lib} #{requires_str} #{bundle_bin}"
99
+
100
+ if exitstatus
101
+ sys_status(cmd)
102
+ else
103
+ sys_exec(cmd, expect_err){|i| yield i if block_given? }
104
+ end
105
+ end
106
+
107
+ def ruby(ruby, options = {})
108
+ expect_err = options.delete(:expect_err)
109
+ env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join
110
+ ruby.gsub!(/["`\$]/) {|m| "\\#{m}" }
111
+ lib_option = options[:no_lib] ? "" : " -I#{lib}"
112
+ sys_exec(%{#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"}, expect_err)
113
+ end
114
+
115
+ def load_error_ruby(ruby, name, opts = {})
116
+ cmd = <<-R
117
+ begin
118
+ #{ruby}
119
+ rescue LoadError => e
120
+ $stderr.puts "ZOMG LOAD ERROR"# if e.message.include?("-- #{name}")
121
+ end
122
+ R
123
+ ruby(cmd, opts.merge(:expect_err => true))
124
+ end
125
+
126
+ def gembin(cmd)
127
+ lib = File.expand_path("../../../lib", __FILE__)
128
+ old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}"
129
+ cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
130
+ sys_exec(cmd.to_s)
131
+ ensure
132
+ ENV['RUBYOPT'] = old
133
+ end
134
+
135
+ def sys_exec(cmd, expect_err = false)
136
+ Open3.popen3(cmd.to_s) do |stdin, stdout, stderr|
137
+ @in_p, @out_p, @err_p = stdin, stdout, stderr
138
+
139
+ yield @in_p if block_given?
140
+ @in_p.close
141
+
142
+ @out = @out_p.read_available_bytes.strip
143
+ @err = @err_p.read_available_bytes.strip
144
+ end
145
+
146
+ puts @err unless expect_err || @err.empty? || !$show_err
147
+ @out
148
+ end
149
+
150
+ def sys_status(cmd)
151
+ @err = nil
152
+ @out = %x{#{cmd}}.strip
153
+ @exitstatus = $?.exitstatus
154
+ end
155
+
156
+ def config(config = nil)
157
+ path = bundled_app('.bundle/config')
158
+ return YAML.load_file(path) unless config
159
+ FileUtils.mkdir_p(File.dirname(path))
160
+ File.open(path, 'w') do |f|
161
+ f.puts config.to_yaml
162
+ end
163
+ config
164
+ end
165
+
166
+ def create_file(*args)
167
+ path = bundled_app(args.shift)
168
+ path = args.shift if args.first.is_a?(Pathname)
169
+ str = args.shift || ""
170
+ path.dirname.mkpath
171
+ File.open(path.to_s, 'w') do |f|
172
+ f.puts strip_whitespace(str)
173
+ end
174
+ end
175
+
176
+ def gemfile(*args)
177
+ create_file("Gemfile", *args)
178
+ end
179
+
180
+ def lockfile(*args)
181
+ create_file("Gemfile.lock", *args)
182
+ end
183
+
184
+ def consolerc(*args)
185
+ create_file(".consolerc", *args)
186
+ end
187
+
188
+ def strip_whitespace(str)
189
+ # Trim the leading spaces
190
+ spaces = str[/\A\s+/, 0] || ""
191
+ str.gsub(/^#{spaces}/, '')
192
+ end
193
+
194
+ def install_gemfile(*args)
195
+ gemfile(*args)
196
+ opts = args.last.is_a?(Hash) ? args.last : {}
197
+ opts[:retry] ||= 0
198
+ bundle :install, opts
199
+ end
200
+
201
+ def install_gems(*gems)
202
+ gems.each do |g|
203
+ path = "#{gem_repo1}/gems/#{g}.gem"
204
+
205
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
206
+
207
+ gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
208
+ end
209
+ end
210
+
211
+ alias install_gem install_gems
212
+
213
+ def with_gem_path_as(path)
214
+ gem_home, gem_path = ENV['GEM_HOME'], ENV['GEM_PATH']
215
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = path.to_s, path.to_s
216
+ yield
217
+ ensure
218
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
219
+ end
220
+
221
+ def break_git!
222
+ FileUtils.mkdir_p(tmp("broken_path"))
223
+ File.open(tmp("broken_path/git"), "w", 0755) do |f|
224
+ f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
225
+ end
226
+
227
+ ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
228
+ end
229
+
230
+ def fake_man!
231
+ FileUtils.mkdir_p(tmp("fake_man"))
232
+ File.open(tmp("fake_man/man"), "w", 0755) do |f|
233
+ f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
234
+ end
235
+
236
+ ENV["PATH"] = "#{tmp("fake_man")}:#{ENV["PATH"]}"
237
+ end
238
+
239
+ def kill_path!
240
+ ENV["PATH"] = ""
241
+ end
242
+
243
+ def system_gems(*gems)
244
+ gems = gems.flatten
245
+
246
+ FileUtils.rm_rf(system_gem_path)
247
+ FileUtils.mkdir_p(system_gem_path)
248
+
249
+ Gem.clear_paths
250
+
251
+ gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
252
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
253
+
254
+ install_gems(*gems)
255
+ if block_given?
256
+ begin
257
+ yield
258
+ ensure
259
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
260
+ ENV['PATH'] = path
261
+ end
262
+ end
263
+ end
264
+
265
+ def realworld_system_gems(*gems)
266
+ gems = gems.flatten
267
+
268
+ FileUtils.rm_rf(system_gem_path)
269
+ FileUtils.mkdir_p(system_gem_path)
270
+
271
+ Gem.clear_paths
272
+
273
+ gem_home, gem_path, path = ENV['GEM_HOME'], ENV['GEM_PATH'], ENV['PATH']
274
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = system_gem_path.to_s, system_gem_path.to_s
275
+
276
+ gems.each do |gem|
277
+ gem_command :install, "--no-rdoc --no-ri #{gem}"
278
+ end
279
+ if block_given?
280
+ begin
281
+ yield
282
+ ensure
283
+ ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
284
+ ENV['PATH'] = path
285
+ end
286
+ end
287
+ end
288
+
289
+ def cache_gems(*gems)
290
+ gems = gems.flatten
291
+
292
+ FileUtils.rm_rf("#{bundled_app}/vendor/cache")
293
+ FileUtils.mkdir_p("#{bundled_app}/vendor/cache")
294
+
295
+ gems.each do |g|
296
+ path = "#{gem_repo1}/gems/#{g}.gem"
297
+ raise "OMG `#{path}` does not exist!" unless File.exist?(path)
298
+ FileUtils.cp(path, "#{bundled_app}/vendor/cache")
299
+ end
300
+ end
301
+
302
+ def simulate_new_machine
303
+ system_gems []
304
+ FileUtils.rm_rf default_bundle_path
305
+ FileUtils.rm_rf bundled_app('.bundle')
306
+ end
307
+
308
+ def simulate_platform(platform)
309
+ old, ENV['BUNDLER_SPEC_PLATFORM'] = ENV['BUNDLER_SPEC_PLATFORM'], platform.to_s
310
+ yield if block_given?
311
+ ensure
312
+ ENV['BUNDLER_SPEC_PLATFORM'] = old if block_given?
313
+ end
314
+
315
+ def simulate_ruby_engine(engine, version = "1.6.0")
316
+ return if engine == local_ruby_engine
317
+
318
+ old, ENV['BUNDLER_SPEC_RUBY_ENGINE'] = ENV['BUNDLER_SPEC_RUBY_ENGINE'], engine
319
+ old_version, ENV['BUNDLER_SPEC_RUBY_ENGINE_VERSION'] = ENV['BUNDLER_SPEC_RUBY_ENGINE_VERSION'], version
320
+ yield if block_given?
321
+ ensure
322
+ ENV['BUNDLER_SPEC_RUBY_ENGINE'] = old if block_given?
323
+ ENV['BUNDLER_SPEC_RUBY_ENGINE_VERSION'] = old_version if block_given?
324
+ end
325
+
326
+ def simulate_bundler_version(version)
327
+ old, ENV['BUNDLER_SPEC_VERSION'] = ENV['BUNDLER_SPEC_VERSION'], version.to_s
328
+ yield if block_given?
329
+ ensure
330
+ ENV['BUNDLER_SPEC_VERSION'] = old if block_given?
331
+ end
332
+
333
+ def revision_for(path)
334
+ Dir.chdir(path) { `git rev-parse HEAD`.strip }
335
+ end
336
+
337
+ def capture_output
338
+ fake_stdout = StringIO.new
339
+ actual_stdout = $stdout
340
+ $stdout = fake_stdout
341
+ yield
342
+ fake_stdout.rewind
343
+ fake_stdout.read
344
+ ensure
345
+ $stdout = actual_stdout
346
+ end
347
+ end
348
+ end
@@ -0,0 +1,280 @@
1
+ module Spec
2
+ module Indexes
3
+ def dep(name, reqs = nil)
4
+ @deps ||= []
5
+ @deps << Bundler::Dependency.new(name, reqs)
6
+ end
7
+
8
+ def platform(*args)
9
+ @platforms ||= []
10
+ @platforms.concat args.map { |p| Gem::Platform.new(p) }
11
+ end
12
+
13
+ alias platforms platform
14
+
15
+ def resolve
16
+ @platforms ||= ['ruby']
17
+ deps = []
18
+ @deps.each do |d|
19
+ @platforms.each do |p|
20
+ deps << Bundler::DepProxy.new(d, p)
21
+ end
22
+ end
23
+ Bundler::Resolver.resolve(deps, @index)
24
+ end
25
+
26
+ def should_resolve_as(specs)
27
+ got = resolve
28
+ got = got.map { |s| s.full_name }.sort
29
+ expect(got).to eq(specs.sort)
30
+ end
31
+
32
+ def should_conflict_on(names)
33
+ begin
34
+ got = resolve
35
+ flunk "The resolve succeeded with: #{got.map { |s| s.full_name }.sort.inspect}"
36
+ rescue Bundler::VersionConflict => e
37
+ expect(Array(names).sort).to eq(e.conflicts.sort)
38
+ end
39
+ end
40
+
41
+ def gem(*args, &blk)
42
+ build_spec(*args, &blk).first
43
+ end
44
+
45
+ def an_awesome_index
46
+ build_index do
47
+ gem "rack", %w(0.8 0.9 0.9.1 0.9.2 1.0 1.1)
48
+ gem "rack-mount", %w(0.4 0.5 0.5.1 0.5.2 0.6)
49
+
50
+ # --- Rails
51
+ versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
52
+ gem "activesupport", version
53
+ gem "actionpack", version do
54
+ dep "activesupport", version
55
+ if version >= v('3.0.0.beta')
56
+ dep "rack", '~> 1.1'
57
+ dep "rack-mount", ">= 0.5"
58
+ elsif version > v('2.3') then dep "rack", '~> 1.0.0'
59
+ elsif version > v('2.0.0') then dep "rack", '~> 0.9.0'
60
+ end
61
+ end
62
+ gem "activerecord", version do
63
+ dep "activesupport", version
64
+ dep "arel", ">= 0.2" if version >= v('3.0.0.beta')
65
+ end
66
+ gem "actionmailer", version do
67
+ dep "activesupport", version
68
+ dep "actionmailer", version
69
+ end
70
+ if version < v('3.0.0.beta')
71
+ gem "railties", version do
72
+ dep "activerecord", version
73
+ dep "actionpack", version
74
+ dep "actionmailer", version
75
+ dep "activesupport", version
76
+ end
77
+ else
78
+ gem "railties", version
79
+ gem "rails", version do
80
+ dep "activerecord", version
81
+ dep "actionpack", version
82
+ dep "actionmailer", version
83
+ dep "activesupport", version
84
+ dep "railties", version
85
+ end
86
+ end
87
+ end
88
+
89
+ versions '1.0 1.2 1.2.1 1.2.2 1.3 1.3.0.1 1.3.5 1.4.0 1.4.2 1.4.2.1' do |version|
90
+ platforms "ruby java mswin32 mingw32 x64-mingw32" do |platform|
91
+ next if version == v('1.4.2.1') && platform != pl('x86-mswin32')
92
+ next if version == v('1.4.2') && platform == pl('x86-mswin32')
93
+ gem "nokogiri", version, platform do
94
+ dep "weakling", ">= 0.0.3" if platform =~ pl('java')
95
+ end
96
+ end
97
+ end
98
+
99
+ versions '0.0.1 0.0.2 0.0.3' do |version|
100
+ gem "weakling", version
101
+ end
102
+
103
+ # --- Rails related
104
+ versions '1.2.3 2.2.3 2.3.5' do |version|
105
+ gem "activemerchant", version do
106
+ dep "activesupport", ">= #{version}"
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ # Builder 3.1.4 will activate first, but if all
113
+ # goes well, it should resolve to 3.0.4
114
+ def a_conflict_index
115
+ build_index do
116
+ gem "builder", %w(3.0.4 3.1.4)
117
+ gem("grape", '0.2.6') do
118
+ dep "builder", ">= 0"
119
+ end
120
+
121
+ versions '3.2.8 3.2.9 3.2.10 3.2.11' do |version|
122
+ gem("activemodel", version) do
123
+ dep "builder", "~> 3.0.0"
124
+ end
125
+ end
126
+
127
+ gem("my_app", '1.0.0') do
128
+ dep "activemodel", ">= 0"
129
+ dep "grape", ">= 0"
130
+ end
131
+ end
132
+ end
133
+
134
+ def a_complex_conflict_index
135
+ build_index do
136
+ gem("a", %w(1.0.2 1.1.4 1.2.0 1.4.0)) do
137
+ dep "d", ">= 0"
138
+ end
139
+
140
+ gem("d", %w(1.3.0 1.4.1)) do
141
+ dep "x", ">= 0"
142
+ end
143
+
144
+ gem "d", "0.9.8"
145
+
146
+ gem("b", '0.3.4') do
147
+ dep "a", ">= 1.5.0"
148
+ end
149
+
150
+ gem("b", '0.3.5') do
151
+ dep "a", ">= 1.2"
152
+ end
153
+
154
+ gem("b", '0.3.3') do
155
+ dep "a", "> 1.0"
156
+ end
157
+
158
+ versions '3.2 3.3' do |version|
159
+ gem("c", version) do
160
+ dep "a", "~> 1.0"
161
+ end
162
+ end
163
+
164
+ gem("my_app", '1.3.0') do
165
+ dep "c", ">= 4.0"
166
+ dep "b", ">= 0"
167
+ end
168
+
169
+ gem("my_app", '1.2.0') do
170
+ dep "c", "~> 3.3.0"
171
+ dep "b", "0.3.4"
172
+ end
173
+
174
+ gem("my_app", '1.1.0') do
175
+ dep "c", "~> 3.2.0"
176
+ dep "b", "0.3.5"
177
+ end
178
+ end
179
+ end
180
+
181
+ def index_with_conflict_on_child
182
+ build_index do
183
+ gem "json", %w(1.6.5 1.7.7 1.8.0)
184
+
185
+ gem("chef", '10.26') do
186
+ dep "json", [">= 1.4.4", "<= 1.7.7"]
187
+ end
188
+
189
+ gem("berkshelf", "2.0.7") do
190
+ dep "json", ">= 1.7.7"
191
+ end
192
+
193
+ gem("chef_app", '1.0.0') do
194
+ dep "berkshelf", "~> 2.0"
195
+ dep "chef", "~> 10.26"
196
+ end
197
+ end
198
+ end
199
+
200
+ def a_unresovable_child_index
201
+ build_index do
202
+ gem "json", %w(1.8.0)
203
+
204
+ gem("chef", '10.26') do
205
+ dep "json", [">= 1.4.4", "<= 1.7.7"]
206
+ end
207
+
208
+ gem("berkshelf", "2.0.7") do
209
+ dep "json", ">= 1.7.7"
210
+ end
211
+
212
+ gem("chef_app_error", '1.0.0') do
213
+ dep "berkshelf", "~> 2.0"
214
+ dep "chef", "~> 10.26"
215
+ end
216
+ end
217
+ end
218
+
219
+ def a_index_with_root_conflict_on_child
220
+ build_index do
221
+ gem "builder", %w(2.1.2 3.0.1 3.1.3)
222
+ gem "i18n", %w(0.4.1 0.4.2)
223
+
224
+ gem "activesupport", %w(3.0.0 3.0.1 3.0.5 3.1.7)
225
+
226
+ gem("activemodel", '3.0.5') do
227
+ dep "activesupport", "= 3.0.5"
228
+ dep "builder", "~> 2.1.2"
229
+ dep 'i18n', '~> 0.4'
230
+ end
231
+
232
+ gem("activemodel", '3.0.0') do
233
+ dep "activesupport", "= 3.0.0"
234
+ dep "builder", "~> 2.1.2"
235
+ dep 'i18n', '~> 0.4.1'
236
+ end
237
+
238
+ gem("activemodel", '3.1.3') do
239
+ dep "activesupport", "= 3.1.3"
240
+ dep "builder", "~> 2.1.2"
241
+ dep 'i18n', '~> 0.5'
242
+ end
243
+
244
+ gem("activerecord", '3.0.0') do
245
+ dep "activesupport", "= 3.0.0"
246
+ dep "activemodel", "= 3.0.0"
247
+ end
248
+
249
+ gem("activerecord", '3.0.5') do
250
+ dep "activesupport", "= 3.0.5"
251
+ dep "activemodel", "= 3.0.5"
252
+ end
253
+
254
+ gem("activerecord", '3.0.9') do
255
+ dep "activesupport", "= 3.1.5"
256
+ dep "activemodel", "= 3.1.5"
257
+ end
258
+ end
259
+ end
260
+
261
+ def a_circular_index
262
+ build_index do
263
+ gem "rack", "1.0.1"
264
+ gem("foo", '0.2.6') do
265
+ dep "bar", ">= 0"
266
+ end
267
+
268
+ gem("bar", "1.0.0") do
269
+ dep "foo", ">= 0"
270
+ end
271
+
272
+ gem("circular_app", '1.0.0') do
273
+ dep "foo", ">= 0"
274
+ dep "bar", ">= 0"
275
+ end
276
+ end
277
+ end
278
+
279
+ end
280
+ end