Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions/easy_compile/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28211,7 +28211,7 @@ async function run(workingDirectory) {
let ccRubies = cp.execSync('easy_compile print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })

await downloadRubies(ccRubies.split(':'))
setupRakeCompilerConfig()
setupRakeCompilerConfig(workingDirectory)
}

async function downloadRubies(rubies) {
Expand All @@ -28227,11 +28227,11 @@ async function downloadRubies(rubies) {
}
}

function setupRakeCompilerConfig() {
function setupRakeCompilerConfig(workingDirectory) {
let rubiesRbConfig = fs.globSync(`${rubiesPath()}/*/*/lib/ruby/*/*/rbconfig.rb`)
let currentRubyVersion = cp.execSync('ruby -v', { encoding: 'utf-8' }).match(/^ruby (\d\.\d\.\d)/)[1]
let rbConfigPath = path.join(os.homedir(), ".rake-compiler", "config.yml")
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { encoding: 'utf-8' })
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })

fs.mkdirSync(`${os.homedir()}/.rake-compiler`)

Expand Down
6 changes: 3 additions & 3 deletions .github/actions/easy_compile/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function run(workingDirectory) {
let ccRubies = cp.execSync('easy_compile print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })

await downloadRubies(ccRubies.split(':'))
setupRakeCompilerConfig()
setupRakeCompilerConfig(workingDirectory)
}

async function downloadRubies(rubies) {
Expand All @@ -26,11 +26,11 @@ async function downloadRubies(rubies) {
}
}

function setupRakeCompilerConfig() {
function setupRakeCompilerConfig(workingDirectory) {
let rubiesRbConfig = fs.globSync(`${rubiesPath()}/*/*/lib/ruby/*/*/rbconfig.rb`)
let currentRubyVersion = cp.execSync('ruby -v', { encoding: 'utf-8' }).match(/^ruby (\d\.\d\.\d)/)[1]
let rbConfigPath = path.join(os.homedir(), ".rake-compiler", "config.yml")
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { encoding: 'utf-8' })
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })

fs.mkdirSync(`${os.homedir()}/.rake-compiler`)

Expand Down
10 changes: 10 additions & 0 deletions lib/easy_compile/compilation_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class CompilationTasks

def initialize(create_packaging_task = false, gemspec = nil)
@gemspec = Bundler.load_gemspec(gemspec || find_gemspec)
verify_gemspec!

@create_packaging_task = create_packaging_task
end
Expand Down Expand Up @@ -126,5 +127,14 @@ def find_gemspec(glob = "*.gemspec")
Make sure to run any easy_compile commands in the root of your gem folder.
EOM
end

def verify_gemspec!
return if gemspec.extensions.any?

raise GemspecError, <<~EOM
Your gem has no native extention defined in its gemspec.
This tool can't be used on pure Ruby gems.
EOM
end
end
end
33 changes: 28 additions & 5 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ def test_when_cli_runs_in_project_with_no_gemspec
out = nil

Dir.chdir("lib") do
Kernel.stub(:exit, ->(_) { raise }) do
out, _ = capture_subprocess_io do
assert_raises(StandardError) do
CLI.start(["print_ruby_cc_version"])
end
out, _ = capture_subprocess_io do
raise_instead_of_exit do
CLI.start(["print_ruby_cc_version"])
end
end
end
Expand All @@ -136,5 +134,30 @@ def test_when_cli_runs_in_project_with_no_gemspec
Make sure to run any easy_compile commands in the root of your gem folder.
MSG
end

def test_when_cli_runs_in_project_with_no_native_extension
out = nil

out, _ = capture_subprocess_io do
raise_instead_of_exit do
CLI.start(["print_ruby_cc_version"])
end
end

assert_equal(<<~MSG, out)
Your gem has no native extention defined in its gemspec.
This tool can't be used on pure Ruby gems.
MSG
end

private

def raise_instead_of_exit(&block)
Kernel.stub(:exit, ->(_) { raise }) do
assert_raises(StandardError) do
block.call
end
end
end
end
end