rubygems-update 3.3.15 → 3.3.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Manifest.txt +5 -2
  4. data/bundler/CHANGELOG.md +6 -0
  5. data/bundler/lib/bundler/build_metadata.rb +2 -2
  6. data/bundler/lib/bundler/cli/cache.rb +1 -1
  7. data/bundler/lib/bundler/cli/install.rb +0 -2
  8. data/bundler/lib/bundler/cli.rb +2 -6
  9. data/bundler/lib/bundler/definition.rb +16 -20
  10. data/bundler/lib/bundler/dependency.rb +2 -0
  11. data/bundler/lib/bundler/dsl.rb +1 -3
  12. data/bundler/lib/bundler/errors.rb +2 -0
  13. data/bundler/lib/bundler/fetcher/base.rb +6 -8
  14. data/bundler/lib/bundler/fetcher.rb +4 -0
  15. data/bundler/lib/bundler/plugin/api/source.rb +3 -3
  16. data/bundler/lib/bundler/resolver.rb +10 -12
  17. data/bundler/lib/bundler/rubygems_gem_installer.rb +8 -0
  18. data/bundler/lib/bundler/rubygems_integration.rb +3 -21
  19. data/bundler/lib/bundler/source/git.rb +5 -7
  20. data/bundler/lib/bundler/source/rubygems.rb +77 -76
  21. data/bundler/lib/bundler/version.rb +1 -1
  22. data/lib/rubygems/commands/install_command.rb +1 -1
  23. data/lib/rubygems/commands/sources_command.rb +1 -1
  24. data/lib/rubygems/core_ext/kernel_require.rb +1 -1
  25. data/lib/rubygems/errors.rb +1 -1
  26. data/lib/rubygems/ext/builder.rb +3 -3
  27. data/lib/rubygems/ext/cargo_builder/link_flag_converter.rb +23 -0
  28. data/lib/rubygems/ext/cargo_builder.rb +87 -64
  29. data/lib/rubygems/gemcutter_utilities.rb +1 -1
  30. data/lib/rubygems/request.rb +1 -1
  31. data/lib/rubygems/source/git.rb +2 -2
  32. data/lib/rubygems/source.rb +2 -9
  33. data/lib/rubygems/source_list.rb +1 -5
  34. data/lib/rubygems/specification.rb +28 -4
  35. data/lib/rubygems/specification_policy.rb +1 -1
  36. data/lib/rubygems/uri.rb +41 -26
  37. data/lib/rubygems/util.rb +1 -1
  38. data/lib/rubygems.rb +1 -2
  39. data/rubygems-update.gemspec +1 -1
  40. data/test/rubygems/data/excon-0.7.7.gemspec.rz +0 -0
  41. data/test/rubygems/data/{null-type.gemspec.rz → pry-0.4.7.gemspec.rz} +0 -0
  42. data/test/rubygems/helper.rb +2 -2
  43. data/test/rubygems/test_gem.rb +1 -1
  44. data/test/rubygems/test_gem_commands_sources_command.rb +50 -0
  45. data/test/rubygems/test_gem_config_file.rb +3 -3
  46. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock +86 -74
  47. data/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml +1 -2
  48. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +86 -74
  49. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +1 -2
  50. data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb +2 -2
  51. data/test/rubygems/test_gem_ext_cargo_builder.rb +50 -19
  52. data/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb +33 -0
  53. data/test/rubygems/test_gem_ext_cargo_builder_unit.rb +75 -0
  54. data/test/rubygems/test_gem_gemcutter_utilities.rb +1 -1
  55. data/test/rubygems/test_gem_package.rb +1 -1
  56. data/test/rubygems/test_gem_remote_fetcher.rb +15 -15
  57. data/test/rubygems/test_gem_resolver.rb +1 -1
  58. data/test/rubygems/test_gem_specification.rb +14 -6
  59. data/test/rubygems/test_require.rb +10 -10
  60. data/test/rubygems/test_rubygems.rb +3 -3
  61. metadata +8 -5
  62. data/lib/rubygems/psych_additions.rb +0 -10
@@ -11,6 +11,15 @@ dependencies = [
11
11
  "memchr",
12
12
  ]
13
13
 
14
+ [[package]]
15
+ name = "ansi_term"
16
+ version = "0.12.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
19
+ dependencies = [
20
+ "winapi",
21
+ ]
22
+
14
23
  [[package]]
15
24
  name = "atty"
16
25
  version = "0.2.14"
@@ -22,16 +31,11 @@ dependencies = [
22
31
  "winapi",
23
32
  ]
24
33
 
25
- [[package]]
26
- name = "autocfg"
27
- version = "1.1.0"
28
- source = "registry+https://github.com/rust-lang/crates.io-index"
29
- checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
30
-
31
34
  [[package]]
32
35
  name = "bindgen"
33
36
  version = "0.59.2"
34
- source = "git+https://github.com/rust-lang/rust-bindgen?rev=f34e4103f304500c96d332f5cecc9067c980d0f9#f34e4103f304500c96d332f5cecc9067c980d0f9"
37
+ source = "registry+https://github.com/rust-lang/crates.io-index"
38
+ checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
35
39
  dependencies = [
36
40
  "bitflags",
37
41
  "cexpr",
@@ -56,6 +60,12 @@ version = "1.3.2"
56
60
  source = "registry+https://github.com/rust-lang/crates.io-index"
57
61
  checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
58
62
 
63
+ [[package]]
64
+ name = "cc"
65
+ version = "1.0.73"
66
+ source = "registry+https://github.com/rust-lang/crates.io-index"
67
+ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
68
+
59
69
  [[package]]
60
70
  name = "cexpr"
61
71
  version = "0.6.0"
@@ -73,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
73
83
 
74
84
  [[package]]
75
85
  name = "clang-sys"
76
- version = "1.3.1"
86
+ version = "1.3.3"
77
87
  source = "registry+https://github.com/rust-lang/crates.io-index"
78
- checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
88
+ checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
79
89
  dependencies = [
80
90
  "glob",
81
91
  "libc",
@@ -84,17 +94,17 @@ dependencies = [
84
94
 
85
95
  [[package]]
86
96
  name = "clap"
87
- version = "3.1.5"
97
+ version = "2.34.0"
88
98
  source = "registry+https://github.com/rust-lang/crates.io-index"
89
- checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312"
99
+ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
90
100
  dependencies = [
101
+ "ansi_term",
91
102
  "atty",
92
103
  "bitflags",
93
- "indexmap",
94
- "os_str_bytes",
95
104
  "strsim",
96
- "termcolor",
97
105
  "textwrap",
106
+ "unicode-width",
107
+ "vec_map",
98
108
  ]
99
109
 
100
110
  [[package]]
@@ -122,12 +132,6 @@ version = "0.3.0"
122
132
  source = "registry+https://github.com/rust-lang/crates.io-index"
123
133
  checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
124
134
 
125
- [[package]]
126
- name = "hashbrown"
127
- version = "0.11.2"
128
- source = "registry+https://github.com/rust-lang/crates.io-index"
129
- checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
130
-
131
135
  [[package]]
132
136
  name = "hermit-abi"
133
137
  version = "0.1.19"
@@ -143,16 +147,6 @@ version = "2.1.0"
143
147
  source = "registry+https://github.com/rust-lang/crates.io-index"
144
148
  checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
145
149
 
146
- [[package]]
147
- name = "indexmap"
148
- version = "1.8.0"
149
- source = "registry+https://github.com/rust-lang/crates.io-index"
150
- checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
151
- dependencies = [
152
- "autocfg",
153
- "hashbrown",
154
- ]
155
-
156
150
  [[package]]
157
151
  name = "lazy_static"
158
152
  version = "1.4.0"
@@ -167,9 +161,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
167
161
 
168
162
  [[package]]
169
163
  name = "libc"
170
- version = "0.2.119"
164
+ version = "0.2.126"
171
165
  source = "registry+https://github.com/rust-lang/crates.io-index"
172
- checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
166
+ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
173
167
 
174
168
  [[package]]
175
169
  name = "libloading"
@@ -181,20 +175,29 @@ dependencies = [
181
175
  "winapi",
182
176
  ]
183
177
 
178
+ [[package]]
179
+ name = "linkify"
180
+ version = "0.8.1"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "28d9967eb7d0bc31c39c6f52e8fce42991c0cd1f7a2078326f0b7a399a584c8d"
183
+ dependencies = [
184
+ "memchr",
185
+ ]
186
+
184
187
  [[package]]
185
188
  name = "log"
186
- version = "0.4.14"
189
+ version = "0.4.17"
187
190
  source = "registry+https://github.com/rust-lang/crates.io-index"
188
- checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
191
+ checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
189
192
  dependencies = [
190
193
  "cfg-if",
191
194
  ]
192
195
 
193
196
  [[package]]
194
197
  name = "memchr"
195
- version = "2.4.1"
198
+ version = "2.5.0"
196
199
  source = "registry+https://github.com/rust-lang/crates.io-index"
197
- checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
200
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
198
201
 
199
202
  [[package]]
200
203
  name = "minimal-lexical"
@@ -204,22 +207,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
204
207
 
205
208
  [[package]]
206
209
  name = "nom"
207
- version = "7.1.0"
210
+ version = "7.1.1"
208
211
  source = "registry+https://github.com/rust-lang/crates.io-index"
209
- checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
212
+ checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
210
213
  dependencies = [
211
214
  "memchr",
212
215
  "minimal-lexical",
213
- "version_check",
214
- ]
215
-
216
- [[package]]
217
- name = "os_str_bytes"
218
- version = "6.0.0"
219
- source = "registry+https://github.com/rust-lang/crates.io-index"
220
- checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
221
- dependencies = [
222
- "memchr",
223
216
  ]
224
217
 
225
218
  [[package]]
@@ -230,43 +223,47 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
230
223
 
231
224
  [[package]]
232
225
  name = "pkg-config"
233
- version = "0.3.24"
226
+ version = "0.3.25"
234
227
  source = "registry+https://github.com/rust-lang/crates.io-index"
235
- checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
228
+ checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
236
229
 
237
230
  [[package]]
238
231
  name = "proc-macro2"
239
- version = "1.0.36"
232
+ version = "1.0.39"
240
233
  source = "registry+https://github.com/rust-lang/crates.io-index"
241
- checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
234
+ checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
242
235
  dependencies = [
243
- "unicode-xid",
236
+ "unicode-ident",
244
237
  ]
245
238
 
246
239
  [[package]]
247
240
  name = "quote"
248
- version = "1.0.15"
241
+ version = "1.0.18"
249
242
  source = "registry+https://github.com/rust-lang/crates.io-index"
250
- checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
243
+ checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
251
244
  dependencies = [
252
245
  "proc-macro2",
253
246
  ]
254
247
 
255
248
  [[package]]
256
249
  name = "rb-sys"
257
- version = "0.6.0"
258
- source = "git+https://github.com/ianks/rb-sys?tag=v0.6.0#1aa5b589e86a14e01aba806511818c19f85d71f6"
250
+ version = "0.9.4"
251
+ source = "registry+https://github.com/rust-lang/crates.io-index"
252
+ checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
259
253
  dependencies = [
260
254
  "bindgen",
261
- "libc",
255
+ "cc",
256
+ "lazy_static",
257
+ "linkify",
262
258
  "pkg-config",
259
+ "shell-words",
263
260
  ]
264
261
 
265
262
  [[package]]
266
263
  name = "regex"
267
- version = "1.5.5"
264
+ version = "1.5.6"
268
265
  source = "registry+https://github.com/rust-lang/crates.io-index"
269
- checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
266
+ checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
270
267
  dependencies = [
271
268
  "aho-corasick",
272
269
  "memchr",
@@ -275,9 +272,9 @@ dependencies = [
275
272
 
276
273
  [[package]]
277
274
  name = "regex-syntax"
278
- version = "0.6.25"
275
+ version = "0.6.26"
279
276
  source = "registry+https://github.com/rust-lang/crates.io-index"
280
- checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
277
+ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
281
278
 
282
279
  [[package]]
283
280
  name = "rust_ruby_example"
@@ -292,6 +289,12 @@ version = "1.1.0"
292
289
  source = "registry+https://github.com/rust-lang/crates.io-index"
293
290
  checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
294
291
 
292
+ [[package]]
293
+ name = "shell-words"
294
+ version = "1.1.0"
295
+ source = "registry+https://github.com/rust-lang/crates.io-index"
296
+ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
297
+
295
298
  [[package]]
296
299
  name = "shlex"
297
300
  version = "1.1.0"
@@ -300,9 +303,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
300
303
 
301
304
  [[package]]
302
305
  name = "strsim"
303
- version = "0.10.0"
306
+ version = "0.8.0"
304
307
  source = "registry+https://github.com/rust-lang/crates.io-index"
305
- checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
308
+ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
306
309
 
307
310
  [[package]]
308
311
  name = "termcolor"
@@ -315,27 +318,36 @@ dependencies = [
315
318
 
316
319
  [[package]]
317
320
  name = "textwrap"
318
- version = "0.15.0"
321
+ version = "0.11.0"
322
+ source = "registry+https://github.com/rust-lang/crates.io-index"
323
+ checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
324
+ dependencies = [
325
+ "unicode-width",
326
+ ]
327
+
328
+ [[package]]
329
+ name = "unicode-ident"
330
+ version = "1.0.0"
319
331
  source = "registry+https://github.com/rust-lang/crates.io-index"
320
- checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
332
+ checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
321
333
 
322
334
  [[package]]
323
- name = "unicode-xid"
324
- version = "0.2.2"
335
+ name = "unicode-width"
336
+ version = "0.1.9"
325
337
  source = "registry+https://github.com/rust-lang/crates.io-index"
326
- checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
338
+ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
327
339
 
328
340
  [[package]]
329
- name = "version_check"
330
- version = "0.9.4"
341
+ name = "vec_map"
342
+ version = "0.8.2"
331
343
  source = "registry+https://github.com/rust-lang/crates.io-index"
332
- checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
344
+ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
333
345
 
334
346
  [[package]]
335
347
  name = "which"
336
- version = "4.2.4"
348
+ version = "4.2.5"
337
349
  source = "registry+https://github.com/rust-lang/crates.io-index"
338
- checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
350
+ checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
339
351
  dependencies = [
340
352
  "either",
341
353
  "lazy_static",
@@ -6,5 +6,4 @@ version = "0.1.0"
6
6
  crate-type = ["cdylib"]
7
7
 
8
8
  [dependencies]
9
- # Needed until bindgen has the `allowlist_file` feature
10
- rb-sys = { git = "https://github.com/ianks/rb-sys", tag = "v0.6.0" }
9
+ rb-sys = "0.9.4"
@@ -15,7 +15,7 @@ gemspec = File.expand_path('rust_ruby_example.gemspec', __dir__)
15
15
 
16
16
  Dir.mktmpdir("rust_ruby_example") do |dir|
17
17
  built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
18
- system *gem, "build", gemspec, "--output", built_gem
19
- system *gem, "install", "--verbose", "--local", built_gem, *ARGV
18
+ system(*gem, "build", gemspec, "--output", built_gem)
19
+ system(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
20
20
  system %q(ruby -rrust_ruby_example -e "puts 'Result: ' + RustRubyExample.reverse('hello world')")
21
21
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'helper'
3
4
  require 'rubygems/ext'
4
5
 
@@ -7,12 +8,9 @@ class TestGemExtCargoBuilder < Gem::TestCase
7
8
  super
8
9
 
9
10
  @rust_envs = {
10
- 'CARGO_HOME' => File.join(@orig_env['HOME'], '.cargo'),
11
- 'RUSTUP_HOME' => File.join(@orig_env['HOME'], '.rustup'),
11
+ 'CARGO_HOME' => ENV.fetch('CARGO_HOME', File.join(@orig_env['HOME'], '.cargo')),
12
+ 'RUSTUP_HOME' => ENV.fetch('RUSTUP_HOME', File.join(@orig_env['HOME'], '.rustup')),
12
13
  }
13
-
14
- system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
15
- pend 'cargo not present' unless $?.success?
16
14
  end
17
15
 
18
16
  def setup_rust_gem(name)
@@ -57,15 +55,35 @@ class TestGemExtCargoBuilder < Gem::TestCase
57
55
  end
58
56
 
59
57
  output = output.join "\n"
60
-
61
58
  bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
62
59
 
63
- require(bundle)
60
+ assert_match "Finished release [optimized] target(s)", output
61
+ assert_ffi_handle bundle, 'Init_rust_ruby_example'
62
+ rescue Exception => e
63
+ pp output if output
64
+
65
+ raise(e)
66
+ end
64
67
 
65
- assert_match RustRubyExample.reverse('hello'), 'olleh'
68
+ def test_build_dev_profile
69
+ skip_unsupported_platforms!
70
+ setup_rust_gem "rust_ruby_example"
66
71
 
67
- assert_match "Compiling rust_ruby_example v0.1.0", output
68
- assert_match "Finished release [optimized] target(s)", output
72
+ output = []
73
+
74
+ Dir.chdir @ext do
75
+ ENV.update(@rust_envs)
76
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
77
+ builder = Gem::Ext::CargoBuilder.new(spec)
78
+ builder.profile = :dev
79
+ builder.build nil, @dest_path, output
80
+ end
81
+
82
+ output = output.join "\n"
83
+ bundle = File.join(@dest_path, "debug/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
84
+
85
+ assert_match "Finished dev [unoptimized + debuginfo] target(s)", output
86
+ assert_ffi_handle bundle, 'Init_rust_ruby_example'
69
87
  rescue Exception => e
70
88
  pp output if output
71
89
 
@@ -98,21 +116,23 @@ class TestGemExtCargoBuilder < Gem::TestCase
98
116
  skip_unsupported_platforms!
99
117
  setup_rust_gem "rust_ruby_example"
100
118
 
119
+ require 'open3'
120
+
101
121
  Dir.chdir @ext do
102
122
  require 'tmpdir'
103
123
 
104
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
124
+ env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
125
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
105
126
 
106
127
  Dir.mktmpdir("rust_ruby_example") do |dir|
107
128
  built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
108
129
  Open3.capture2e(*gem, "build", "rust_ruby_example.gemspec", "--output", built_gem)
109
130
  Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
110
- end
111
131
 
112
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rrust_ruby_example", "-e", "puts 'Result: ' + RustRubyExample.reverse('hello world')")
113
-
114
- assert status.success?, stdout_and_stderr_str
115
- assert_match "Result: #{"hello world".reverse}", stdout_and_stderr_str
132
+ stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *ruby_with_rubygems_in_load_path, "-rrust_ruby_example", "-e", "puts 'Result: ' + RustRubyExample.reverse('hello world')")
133
+ assert status.success?, stdout_and_stderr_str
134
+ assert_match "Result: #{"hello world".reverse}", stdout_and_stderr_str
135
+ end
116
136
  end
117
137
  end
118
138
 
@@ -123,7 +143,8 @@ class TestGemExtCargoBuilder < Gem::TestCase
123
143
  Dir.chdir @ext do
124
144
  require 'tmpdir'
125
145
 
126
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
146
+ env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
147
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
127
148
 
128
149
  Dir.mktmpdir("custom_name") do |dir|
129
150
  built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
@@ -131,17 +152,27 @@ class TestGemExtCargoBuilder < Gem::TestCase
131
152
  Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
132
153
  end
133
154
 
134
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rcustom_name", "-e", "puts 'Result: ' + CustomName.say_hello")
155
+ stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *ruby_with_rubygems_in_load_path, "-rcustom_name", "-e", "puts 'Result: ' + CustomName.say_hello")
135
156
 
136
157
  assert status.success?, stdout_and_stderr_str
137
158
  assert_match "Result: Hello world!", stdout_and_stderr_str
138
159
  end
139
160
  end
140
161
 
162
+ private
163
+
141
164
  def skip_unsupported_platforms!
142
165
  pend "jruby not supported" if java_platform?
143
166
  pend "truffleruby not supported (yet)" if RUBY_ENGINE == 'truffleruby'
144
167
  pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS')
145
- pend "ruby.h is not provided by ruby repo" if testing_ruby_repo?
168
+ system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
169
+ pend 'cargo not present' unless $?.success?
170
+ pend "ruby.h is not provided by ruby repo" if ruby_repo?
171
+ end
172
+
173
+ def assert_ffi_handle(bundle, name)
174
+ require 'fiddle'
175
+ dylib_handle = Fiddle.dlopen bundle
176
+ assert_nothing_raised { dylib_handle[name] }
146
177
  end
147
178
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'helper'
3
+ require 'rubygems/ext'
4
+ require 'rubygems/ext/cargo_builder/link_flag_converter'
5
+
6
+ class TestGemExtCargoBuilderLinkFlagConverter < Gem::TestCase
7
+ CASES = {
8
+ test_search_path_basic: ["-L/usr/local/lib", ["-L", "native=/usr/local/lib"]],
9
+ test_search_path_space: ["-L /usr/local/lib", ["-L", "native=/usr/local/lib"]],
10
+ test_search_path_space_in_path: ["-L/usr/local/my\ lib", ["-L", "native=/usr/local/my\ lib"]],
11
+ test_simple_lib: ["-lfoo", ["-l", "foo"]],
12
+ test_lib_with_nonascii: ["-lws2_32", ["-l", "ws2_32"]],
13
+ test_simple_lib_space: ["-l foo", ["-l", "foo"]],
14
+ test_verbose_lib_space: ["--library=foo", ["-l", "foo"]],
15
+ test_libstatic_with_colon: ["-l:libssp.a", ["-l", "static=ssp"]],
16
+ test_libstatic_with_colon_space: ["-l :libssp.a", ["-l", "static=ssp"]],
17
+ test_unconventional_lib_with_colon: ["-l:ssp.a", ["-C", "link_arg=-l:ssp.a"]],
18
+ test_dylib_with_colon_space: ["-l :libssp.dylib", ["-l", "dylib=ssp"]],
19
+ test_so_with_colon_space: ["-l :libssp.so", ["-l", "dylib=ssp"]],
20
+ test_dll_with_colon_space: ["-l :libssp.dll", ["-l", "dylib=ssp"]],
21
+ test_framework: ["-F/some/path", ["-l", "framework=/some/path"]],
22
+ test_framework_space: ["-F /some/path", ["-l", "framework=/some/path"]],
23
+ test_non_lib_dash_l: ["test_rubygems_20220413-976-lemgf9/prefix", ["-C", "link_arg=test_rubygems_20220413-976-lemgf9/prefix"]],
24
+ }.freeze
25
+
26
+ CASES.each do |test_name, (arg, expected)|
27
+ raise "duplicate test name" if instance_methods.include?(test_name)
28
+
29
+ define_method(test_name) do
30
+ assert_equal(expected, Gem::Ext::CargoBuilder::LinkFlagConverter.convert(arg))
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helper'
4
+ require 'rubygems/ext'
5
+
6
+ class TestGemExtCargoBuilderUnit < Gem::TestCase
7
+ def test_cargo_command_passes_args
8
+ skip_unsupported_platforms!
9
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
10
+ builder = Gem::Ext::CargoBuilder.new(spec)
11
+ command = builder.cargo_command(Dir.pwd, @tempdir, ['--all-features'])
12
+
13
+ assert_includes command, '--all-features'
14
+ end
15
+
16
+ def test_cargo_command_locks_in_release_profile
17
+ skip_unsupported_platforms!
18
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
19
+ builder = Gem::Ext::CargoBuilder.new(spec)
20
+ builder.profile = :release
21
+ command = builder.cargo_command(Dir.pwd, @tempdir)
22
+
23
+ assert_includes command, '--locked'
24
+ end
25
+
26
+ def test_cargo_command_does_not_lock_in_dev_profile
27
+ skip_unsupported_platforms!
28
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
29
+ builder = Gem::Ext::CargoBuilder.new(spec)
30
+ builder.profile = :dev
31
+ command = builder.cargo_command(Dir.pwd, @tempdir)
32
+
33
+ assert_not_includes command, '--locked'
34
+ end
35
+
36
+ def test_cargo_command_passes_respects_cargo_env_var
37
+ skip_unsupported_platforms!
38
+ old_cargo = ENV['CARGO']
39
+ ENV['CARGO'] = 'mycargo'
40
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
41
+ builder = Gem::Ext::CargoBuilder.new(spec)
42
+ command = builder.cargo_command(Dir.pwd, @tempdir)
43
+
44
+ assert_includes command, 'mycargo'
45
+ ensure
46
+ ENV['CARGO'] = old_cargo
47
+ end
48
+
49
+ def test_build_env_includes_rbconfig
50
+ skip_unsupported_platforms!
51
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
52
+ builder = Gem::Ext::CargoBuilder.new(spec)
53
+ env = builder.build_env
54
+
55
+ assert_equal env.fetch('RBCONFIG_RUBY_SO_NAME'), RbConfig::CONFIG['RUBY_SO_NAME']
56
+ end
57
+
58
+ def test_cargo_command_passes_respects_cargo_build_target
59
+ skip_unsupported_platforms!
60
+ old_cargo = ENV['CARGO_BUILD_TARGET']
61
+ ENV['CARGO_BUILD_TARGET'] = 'x86_64-unknown-linux-gnu'
62
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
63
+ builder = Gem::Ext::CargoBuilder.new(spec)
64
+ command = builder.cargo_command(Dir.pwd, @tempdir, ['--locked'])
65
+
66
+ assert_includes command, '--target'
67
+ assert_includes command, 'x86_64-unknown-linux-gnu'
68
+ ensure
69
+ ENV['CARGO_BUILD_TARGET'] = old_cargo
70
+ end
71
+
72
+ def skip_unsupported_platforms!
73
+ pend "jruby not supported" if java_platform?
74
+ end
75
+ end
@@ -254,7 +254,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
254
254
  end
255
255
 
256
256
  def test_verify_api_key
257
- keys = {:other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'}
257
+ keys = { :other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' }
258
258
  File.open Gem.configuration.credentials_path, 'w' do |f|
259
259
  f.write keys.to_yaml
260
260
  end
@@ -218,7 +218,7 @@ class TestGemPackage < Gem::Package::TarTestCase
218
218
  end
219
219
 
220
220
  assert_equal %w[lib/code.rb], files
221
- assert_equal [{'lib/code_sym.rb' => 'code.rb'}, {'lib/code_sym2.rb' => '../lib/code.rb'}], symlinks
221
+ assert_equal [{ 'lib/code_sym.rb' => 'code.rb' }, { 'lib/code_sym2.rb' => '../lib/code.rb' }], symlinks
222
222
  end
223
223
 
224
224
  def test_build