Skip to content

Commit 6614181

Browse files
RyanBrushettparacycle
authored andcommitted
Merge pull request #460 from Shopify/ryanb-fix-materialized-dependencies
Fix materialized deps
1 parent dd3888d commit 6614181

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

lib/tapioca/gemfile.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ def materialize_deps
6767
deps = definition.locked_gems.dependencies.values
6868
missing_specs = T::Array[String].new
6969
materialized_dependencies = if definition.resolve.method(:materialize).arity == 1 # Support bundler >= v2.2.25
70-
definition.resolve.materialize(deps)
71-
.tap { |md| missing_specs = T.cast(md.missing_specs, T::Array[String]) }
70+
md = definition.resolve.materialize(deps)
71+
missing_spec_names = md.missing_specs.map(&:name)
72+
missing_specs = T.cast(md.missing_specs.map { |spec| "#{spec.name} (#{spec.version})" }, T::Array[String])
73+
md.to_a.reject { |spec| missing_spec_names.include?(spec.name) }
7274
else
7375
definition.resolve.materialize(deps, missing_specs)
7476
end

spec/support/repo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Gemfile.lock
22
.bundle/
3+
Gemfile.lock

spec/support/repo/Gemfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
source("https://rubygems.org")
44

5-
nokogiri_installable = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5")
6-
75
gem("foo", path: "../gems/foo")
86
gem("bar", path: "../gems/bar")
97
gem("baz", path: "../gems/baz")
@@ -16,10 +14,13 @@ gem("psych")
1614
# ensure that we don't fail.
1715
gem("extras")
1816
# Needed for DSL generation tests. The simplest
19-
# gem that we have a DSL generator for.
20-
gem("smart_properties")
21-
gem("activesupport")
17+
# gems that we have a DSL generator for.
18+
gem("smart_properties", "1.15.0")
19+
gem("activesupport", "5.2.6")
2220
# Needed to test Git gems
2321
gem("ast", git: "https://github.com/whitequark/ast", ref: "e07a4f66e05ac7972643a8841e336d327ea78ae1")
22+
2423
# Needed to test missing gems
25-
gem("nokogiri", ">= 1.11.1") if nokogiri_installable
24+
platform :truffleruby do
25+
gem "minitest-excludes"
26+
end

spec/tapioca/cli_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def execute(command, args = [], flags = {})
9494
@repo_path = (Pathname.new(__dir__) / ".." / "support" / "repo").expand_path
9595
Bundler.with_unbundled_env do
9696
IO.popen(["bundle", "install", "--quiet"], chdir: @repo_path).read
97-
IO.popen(["bundle", "lock", "--add-platform=ruby"], chdir: @repo_path).read
9897
end
9998
end
10099

@@ -814,18 +813,13 @@ class Foo::Secret; end
814813
end
815814

816815
it 'must not generate RBIs for missing gem specs' do
817-
skip "failure is to be investigated later"
818816
output = execute("generate")
819817

820-
assert_includes(output, <<~OUTPUT.strip) if ruby_version(">= 2.5")
821-
Requiring all gems to prepare for compiling... Done
822-
completed with missing specs: mini_portile2
823-
OUTPUT
818+
missing_spec = " completed with missing specs: minitest-excludes (2.0.1)"
819+
assert_includes(output, missing_spec)
824820

825-
refute_includes(output, <<~OUTPUT.strip)
826-
Processing 'mini_portile2' gem:
827-
Compiling mini_portile2, this may take a few seconds... Done
828-
OUTPUT
821+
compiling_spec = " Compiling minitest-excludes, this may take a few seconds"
822+
refute_includes(output, compiling_spec)
829823
end
830824

831825
it 'must generate git gem RBIs with source revision numbers' do

0 commit comments

Comments
 (0)