Skip to content

Commit

Permalink
Also precompile Rake files
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Mar 9, 2022
1 parent 57d883d commit 135eb5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* `bootsnap precompile` CLI will now also precompile `Rakefile` and `.rake` files.

* Remove `uname` and other patform specific version from the cache keys. `RUBY_PLATFORM + RUBY_REVISION` should be
enough to ensure bytecode compatibility. This should improve caching for alpine based setups. See #409.

Expand Down
2 changes: 1 addition & 1 deletion lib/bootsnap/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def precompile_ruby_files(load_paths, exclude: self.exclude)

load_paths.each do |path|
if !exclude || !exclude.match?(path)
list_files(path, "**/*.rb").each do |ruby_file|
list_files(path, "**/{*.rb,*.rake,Rakefile}").each do |ruby_file|
if !exclude || !exclude.match?(ruby_file)
@work_pool.push(:ruby, ruby_file)
end
Expand Down
12 changes: 12 additions & 0 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ def test_precompile_single_file
assert_equal 0, CLI.new(["precompile", "-j", "0", path]).run
end

def test_precompile_rake_files
path = Help.set_file("a.rake", "a = a = 3", 100)
CompileCache::ISeq.expects(:precompile).with(File.expand_path(path))
assert_equal 0, CLI.new(["precompile", "-j", "0", path]).run
end

def test_precompile_rakefile
path = Help.set_file("Rakefile", "a = a = 3", 100)
CompileCache::ISeq.expects(:precompile).with(File.expand_path(path))
assert_equal 0, CLI.new(["precompile", "-j", "0", path]).run
end

def test_no_iseq
path = Help.set_file("a.rb", "a = a = 3", 100)
CompileCache::ISeq.expects(:precompile).never
Expand Down

0 comments on commit 135eb5c

Please sign in to comment.