Skip to content

Commit 90305ce

Browse files
authored
Merge pull request #2624 from Shopify/kaan/warn-missing-rbs-cache-env
Warn when `--only-bootsnap-rbs-cache` runs without `TAPIOCA_RBS_CACHE=1`
2 parents 76f5946 + da5cc20 commit 90305ce

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

lib/tapioca/commands/dsl_generate.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ def execute
1818
load_application
1919

2020
if @only_bootsnap_rbs_cache
21-
say("Bootsnap RBS cache populated, exiting before RBI generation.", :green)
21+
if ENV["TAPIOCA_RBS_CACHE"] == "1"
22+
say("Bootsnap RBS cache populated, exiting before RBI generation.", :green)
23+
else
24+
say_error("Warning: --only-bootsnap-rbs-cache requires TAPIOCA_RBS_CACHE=1 to populate the cache", :yellow)
25+
end
2226
return
2327
end
2428

spec/tapioca/cli/dsl_spec.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,34 @@ class Post
669669
end
670670
RB
671671

672-
result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post")
672+
result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post", env: { "TAPIOCA_RBS_CACHE" => "1" })
673673

674674
assert_stdout_includes(result, <<~OUT)
675675
Bootsnap RBS cache populated, exiting before RBI generation.
676676
OUT
677677

678-
assert_empty_stderr(result)
678+
assert_stderr_includes(result, "bootsnap miss:")
679+
refute_project_file_exist("sorbet/rbi/dsl/post.rbi")
680+
assert_success_status(result)
681+
end
682+
683+
it "warns when --only-bootsnap-rbs-cache is set without TAPIOCA_RBS_CACHE=1" do
684+
@project.write!("lib/post.rb", <<~RB)
685+
require "smart_properties"
686+
687+
class Post
688+
include SmartProperties
689+
property :title, accepts: String
690+
end
691+
RB
692+
693+
result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post")
694+
695+
assert_stderr_includes(
696+
result,
697+
"Warning: --only-bootsnap-rbs-cache requires TAPIOCA_RBS_CACHE=1 to populate the cache",
698+
)
699+
refute_includes(result.out, "Bootsnap RBS cache populated")
679700
refute_project_file_exist("sorbet/rbi/dsl/post.rbi")
680701
assert_success_status(result)
681702
end

0 commit comments

Comments
 (0)