summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_ext_cmake_builder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rubygems/test_gem_ext_cmake_builder.rb')
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb45
1 files changed, 24 insertions, 21 deletions
diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb
index 5ab82c545f..5f886af05f 100644
--- a/test/rubygems/test_gem_ext_cmake_builder.rb
+++ b/test/rubygems/test_gem_ext_cmake_builder.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
-require_relative 'helper'
-require 'rubygems/ext'
+
+require_relative "helper"
+require "rubygems/ext"
class TestGemExtCmakeBuilder < Gem::TestCase
def setup
@@ -9,22 +10,24 @@ class TestGemExtCmakeBuilder < Gem::TestCase
# Details: https://github.com/rubygems/rubygems/issues/1270#issuecomment-177368340
pend "CmakeBuilder doesn't work on Windows." if Gem.win_platform?
+ require "open3"
+
begin
- _, status = Open3.capture2e('cmake')
- pend 'cmake not present' unless status.success?
+ _, status = Open3.capture2e("cmake")
+ pend "cmake not present" unless status.success?
rescue Errno::ENOENT
- pend 'cmake not present'
+ pend "cmake not present"
end
- @ext = File.join @tempdir, 'ext'
- @dest_path = File.join @tempdir, 'prefix'
+ @ext = File.join @tempdir, "ext"
+ @dest_path = File.join @tempdir, "prefix"
FileUtils.mkdir_p @ext
FileUtils.mkdir_p @dest_path
end
def test_self_build
- File.open File.join(@ext, 'CMakeLists.txt'), 'w' do |cmakelists|
+ File.open File.join(@ext, "CMakeLists.txt"), "w" do |cmakelists|
cmakelists.write <<-EO_CMAKE
cmake_minimum_required(VERSION 2.6)
project(self_build NONE)
@@ -32,7 +35,7 @@ install (FILES test.txt DESTINATION bin)
EO_CMAKE
end
- FileUtils.touch File.join(@ext, 'test.txt')
+ FileUtils.touch File.join(@ext, "test.txt")
output = []
@@ -40,11 +43,11 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n"
- assert_match %r{^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output
- assert_match %r{#{Regexp.escape @ext}}, output
- assert_contains_make_command '', output
- assert_contains_make_command 'install', output
- assert_match %r{test\.txt}, output
+ assert_match(/^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}/, output)
+ assert_match(/#{Regexp.escape @ext}/, output)
+ assert_contains_make_command "", output
+ assert_contains_make_command "install", output
+ assert_match(/test\.txt/, output)
end
def test_self_build_fail
@@ -56,16 +59,16 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n"
- shell_error_msg = %r{(CMake Error: .*)}
+ shell_error_msg = /(CMake Error: .*)/
- assert_match 'cmake failed', error.message
+ assert_match "cmake failed", error.message
- assert_match %r{^cmake . -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output
- assert_match %r{#{shell_error_msg}}, output
+ assert_match(/^cmake . -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}/, output)
+ assert_match(/#{shell_error_msg}/, output)
end
def test_self_build_has_makefile
- File.open File.join(@ext, 'Makefile'), 'w' do |makefile|
+ File.open File.join(@ext, "Makefile"), "w" do |makefile|
makefile.puts "all:\n\t@echo ok\ninstall:\n\t@echo ok"
end
@@ -75,7 +78,7 @@ install (FILES test.txt DESTINATION bin)
output = output.join "\n"
- assert_contains_make_command '', output
- assert_contains_make_command 'install', output
+ assert_contains_make_command "", output
+ assert_contains_make_command "install", output
end
end