mini_portile2 2.4.0 → 2.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +2 -0
- data/.github/workflows/ci.yml +88 -0
- data/.gitignore +4 -5
- data/CHANGELOG.md +117 -0
- data/Gemfile +2 -0
- data/README.md +102 -2
- data/Rakefile +2 -6
- data/SECURITY.md +13 -0
- data/lib/mini_portile2/mini_portile.rb +286 -58
- data/lib/mini_portile2/mini_portile_cmake.rb +111 -7
- data/lib/mini_portile2/version.rb +1 -1
- data/mini_portile2.gemspec +24 -23
- data/test/assets/pkgconf/libxml2/libxml-2.0.pc +13 -0
- data/test/assets/pkgconf/libxslt/libexslt.pc +13 -0
- data/test/assets/pkgconf/libxslt/libxslt.pc +13 -0
- data/test/assets/test-download-archive.tar.gz +0 -0
- data/test/helper.rb +16 -0
- data/test/test_activate.rb +139 -0
- data/test/test_cmake.rb +217 -20
- data/test/test_cook.rb +55 -0
- data/test/test_download.rb +7 -5
- data/test/test_execute.rb +39 -0
- data/test/test_mkmf_config.rb +202 -0
- data/test/test_recipe.rb +18 -0
- metadata +42 -31
- data/.concourse.yml +0 -83
- data/.travis.yml +0 -15
- data/appveyor.yml +0 -25
- data/concourse/mini_portile.yml +0 -141
- data/concourse/tasks/rake-test/task.ps1 +0 -11
- data/concourse/tasks/rake-test/task.sh +0 -13
data/mini_portile2.gemspec
CHANGED
@@ -1,42 +1,43 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mini_portile2/version'
|
1
|
+
require_relative "lib/mini_portile2/version"
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
4
|
+
spec.name = "mini_portile2"
|
5
|
+
spec.version = MiniPortile::VERSION
|
9
6
|
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
7
|
+
spec.authors = ["Luis Lavena", "Mike Dalessio", "Lars Kanis"]
|
8
|
+
spec.email = "mike.dalessio@gmail.com"
|
12
9
|
|
13
|
-
spec.summary
|
14
|
-
spec.description
|
10
|
+
spec.summary = "Simple autoconf and cmake builder for developers"
|
11
|
+
spec.description = <<~TEXT
|
12
|
+
Simple autoconf and cmake builder for developers. It provides a standard way to compile against
|
13
|
+
dependency libraries without requiring system-wide installation. It also simplifies
|
14
|
+
vendoring and cross-compilation by providing a consistent build interface.
|
15
|
+
TEXT
|
15
16
|
|
16
|
-
spec.homepage
|
17
|
-
spec.licenses
|
17
|
+
spec.homepage = "https://github.com/flavorjones/mini_portile"
|
18
|
+
spec.licenses = ["MIT"]
|
18
19
|
|
19
20
|
begin
|
20
|
-
spec.files
|
21
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
22
|
rescue Exception => e
|
22
23
|
warn "WARNING: could not set spec.files: #{e.class}: #{e}"
|
23
24
|
end
|
24
25
|
|
25
26
|
# omit the `examples` directory from the gem, because it's large and
|
26
27
|
# not necessary to be packaged in the gem.
|
27
|
-
example_files
|
28
|
+
example_files = spec.files.grep(%r{^examples/})
|
28
29
|
spec.files -= example_files
|
29
30
|
|
30
|
-
spec.executables
|
31
|
-
spec.test_files
|
31
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
32
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|examples)/})
|
32
33
|
spec.require_paths = ["lib"]
|
33
34
|
|
34
|
-
spec.
|
35
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
36
|
-
spec.add_development_dependency "minitest", "~> 5.11"
|
37
|
-
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
38
|
-
spec.add_development_dependency "minitar", "~> 0.7"
|
39
|
-
spec.add_development_dependency "concourse", "~> 0.16"
|
35
|
+
spec.required_ruby_version = ">= 2.3.0"
|
40
36
|
|
41
|
-
spec.
|
37
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
38
|
+
spec.add_development_dependency "minitar", "~> 0.9"
|
39
|
+
spec.add_development_dependency "minitest", "~> 5.15"
|
40
|
+
spec.add_development_dependency "minitest-hooks", "~> 1.5"
|
41
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
42
|
+
spec.add_development_dependency "webrick", "~> 1.7"
|
42
43
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxml2/2.11.5
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxml2/2.11.5/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
modules=1
|
6
|
+
|
7
|
+
Name: libXML
|
8
|
+
Version: 2.11.5
|
9
|
+
Description: libXML library version2.
|
10
|
+
Requires:
|
11
|
+
Libs: -L${libdir} -lxml2
|
12
|
+
Libs.private: -L/foo/zlib/1.3/lib -lz -lm
|
13
|
+
Cflags: -I${includedir}/libxml2 -ggdb3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxslt/1.1.38
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxslt/1.1.38/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
|
6
|
+
|
7
|
+
Name: libexslt
|
8
|
+
Version: 0.8.21
|
9
|
+
Description: EXSLT Extension library
|
10
|
+
Requires: libxml-2.0, libxslt
|
11
|
+
Cflags: -I${includedir}
|
12
|
+
Libs: -L${libdir} -lexslt
|
13
|
+
Libs.private: -lm
|
@@ -0,0 +1,13 @@
|
|
1
|
+
prefix=/foo/libxslt/1.1.38
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=/foo/libxslt/1.1.38/lib
|
4
|
+
includedir=${prefix}/include
|
5
|
+
|
6
|
+
|
7
|
+
Name: libxslt
|
8
|
+
Version: 1.1.38
|
9
|
+
Description: XSLT library version 2.
|
10
|
+
Requires: libxml-2.0
|
11
|
+
Cflags: -I${includedir} -Wno-deprecated-enum-enum-conversion
|
12
|
+
Libs: -L${libdir} -lxslt
|
13
|
+
Libs.private: -lm
|
Binary file
|
data/test/helper.rb
CHANGED
@@ -57,4 +57,20 @@ class TestCase < Minitest::Test
|
|
57
57
|
ensure
|
58
58
|
ENV['GIT_DIR'] = old
|
59
59
|
end
|
60
|
+
|
61
|
+
def with_env(env)
|
62
|
+
before = ENV.to_h.dup
|
63
|
+
env.each { |k, v| ENV[k] = v }
|
64
|
+
yield
|
65
|
+
ensure
|
66
|
+
ENV.replace(before)
|
67
|
+
end
|
68
|
+
|
69
|
+
def without_env(*keys, &blk)
|
70
|
+
before = ENV.to_h.dup
|
71
|
+
keys.flatten.each { |k| ENV.delete(k) }
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
ENV.replace(before)
|
75
|
+
end
|
60
76
|
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestActivate < TestCase
|
4
|
+
attr_reader :recipe
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@save_env = %w[PATH CPATH LIBRARY_PATH LDFLAGS].inject({}) do |env, var|
|
10
|
+
env.update(var => ENV[var])
|
11
|
+
end
|
12
|
+
|
13
|
+
FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
|
14
|
+
|
15
|
+
@recipe = MiniPortile.new("foo", "1.0.0").tap do |recipe|
|
16
|
+
recipe.logger = StringIO.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
FileUtils.rm_rf(["tmp", "ports"]) # remove any previous test files
|
22
|
+
|
23
|
+
@save_env.each do |var, val|
|
24
|
+
ENV[var] = val
|
25
|
+
end
|
26
|
+
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_PATH_env_var_when_bin_does_not_exist
|
31
|
+
ENV["PATH"] = "foo"
|
32
|
+
refute(Dir.exist?(bin_path))
|
33
|
+
refute_includes(path_elements('PATH'), bin_path)
|
34
|
+
|
35
|
+
recipe.activate
|
36
|
+
|
37
|
+
refute_includes(path_elements('PATH'), bin_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_PATH_env_var_when_bin_exists
|
41
|
+
ENV["PATH"] = "foo"
|
42
|
+
FileUtils.mkdir_p(bin_path)
|
43
|
+
refute_includes(path_elements('PATH'), bin_path)
|
44
|
+
|
45
|
+
recipe.activate
|
46
|
+
|
47
|
+
assert_includes(path_elements('PATH'), bin_path)
|
48
|
+
assert_equal(path_elements('PATH').first, bin_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_CPATH_env_var_when_include_does_not_exist
|
52
|
+
ENV["CPATH"] = "foo"
|
53
|
+
refute(Dir.exist?(include_path))
|
54
|
+
refute_includes(path_elements('CPATH'), include_path)
|
55
|
+
|
56
|
+
recipe.activate
|
57
|
+
|
58
|
+
refute_includes(path_elements('CPATH'), include_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_CPATH_env_var_when_include_exists
|
62
|
+
ENV["CPATH"] = "foo"
|
63
|
+
FileUtils.mkdir_p(include_path)
|
64
|
+
refute_includes(path_elements('CPATH'), include_path)
|
65
|
+
|
66
|
+
recipe.activate
|
67
|
+
|
68
|
+
assert_includes(path_elements('CPATH'), include_path)
|
69
|
+
assert_equal(path_elements('CPATH').first, include_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_LIBRARY_PATH_env_var_when_lib_does_not_exist
|
73
|
+
ENV["LIBRARY_PATH"] = "foo"
|
74
|
+
refute(Dir.exist?(lib_path))
|
75
|
+
refute_includes(path_elements('LIBRARY_PATH'), lib_path)
|
76
|
+
|
77
|
+
recipe.activate
|
78
|
+
|
79
|
+
refute_includes(path_elements('LIBRARY_PATH'), lib_path)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_LIBRARY_PATH_env_var_when_lib_exists
|
83
|
+
ENV["LIBRARY_PATH"] = "foo"
|
84
|
+
FileUtils.mkdir_p(lib_path)
|
85
|
+
refute_includes(path_elements('LIBRARY_PATH'), lib_path)
|
86
|
+
|
87
|
+
recipe.activate
|
88
|
+
|
89
|
+
assert_includes(path_elements('LIBRARY_PATH'), lib_path)
|
90
|
+
assert_equal(path_elements('LIBRARY_PATH').first, lib_path)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_LDFLAGS_env_var_when_not_cross_compiling
|
94
|
+
ENV["LDFLAGS"] = "-lfoo"
|
95
|
+
FileUtils.mkdir_p(lib_path)
|
96
|
+
assert_equal(recipe.host, recipe.original_host) # assert on setup)
|
97
|
+
|
98
|
+
refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
|
99
|
+
|
100
|
+
recipe.activate
|
101
|
+
|
102
|
+
refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_LDFLAGS_env_var_when_cross_compiling
|
106
|
+
ENV["LDFLAGS"] = "-lfoo"
|
107
|
+
recipe.host = recipe.original_host + "-x" # make them not-equal
|
108
|
+
FileUtils.mkdir_p(lib_path)
|
109
|
+
|
110
|
+
refute_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
|
111
|
+
|
112
|
+
recipe.activate
|
113
|
+
|
114
|
+
assert_includes(flag_elements('LDFLAGS'), "-L#{lib_path}")
|
115
|
+
assert_equal(flag_elements('LDFLAGS').first, "-L#{lib_path}")
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def path_elements(varname)
|
121
|
+
ENV.fetch(varname, "").split(File::PATH_SEPARATOR)
|
122
|
+
end
|
123
|
+
|
124
|
+
def flag_elements(varname)
|
125
|
+
ENV.fetch(varname, "").split
|
126
|
+
end
|
127
|
+
|
128
|
+
def bin_path
|
129
|
+
MiniPortile.native_path(File.join(recipe.path, "bin"))
|
130
|
+
end
|
131
|
+
|
132
|
+
def include_path
|
133
|
+
MiniPortile.native_path(File.join(recipe.path, "include"))
|
134
|
+
end
|
135
|
+
|
136
|
+
def lib_path
|
137
|
+
MiniPortile.native_path(File.join(recipe.path, "lib"))
|
138
|
+
end
|
139
|
+
end
|
data/test/test_cmake.rb
CHANGED
@@ -5,8 +5,6 @@ class TestCMake < TestCase
|
|
5
5
|
|
6
6
|
def before_all
|
7
7
|
super
|
8
|
-
return if MiniPortile.windows?
|
9
|
-
|
10
8
|
@assets_path = File.expand_path("../assets", __FILE__)
|
11
9
|
@tar_path = File.expand_path("../../tmp/test-cmake-1.0.tar.gz", __FILE__)
|
12
10
|
|
@@ -16,32 +14,32 @@ class TestCMake < TestCase
|
|
16
14
|
create_tar(@tar_path, @assets_path, "test-cmake-1.0")
|
17
15
|
start_webrick(File.dirname(@tar_path))
|
18
16
|
|
19
|
-
@recipe =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
with_custom_git_dir(git_dir) do
|
25
|
-
recipe.cook
|
26
|
-
end
|
17
|
+
@recipe = init_recipe
|
18
|
+
|
19
|
+
git_dir = File.join(@assets_path, "git")
|
20
|
+
with_custom_git_dir(git_dir) do
|
21
|
+
recipe.cook
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
30
25
|
def after_all
|
31
26
|
super
|
32
|
-
return if MiniPortile.windows?
|
33
|
-
|
34
27
|
stop_webrick
|
35
28
|
# leave test files for inspection
|
36
29
|
end
|
37
30
|
|
31
|
+
def exe_name
|
32
|
+
case
|
33
|
+
when MiniPortile.windows? then "hello.exe"
|
34
|
+
else "hello"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
38
|
def test_cmake_inherits_from_base
|
39
39
|
assert(MiniPortileCMake <= MiniPortile)
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_configure
|
43
|
-
skip if MiniPortile.windows?
|
44
|
-
|
45
43
|
cmakecache = File.join(work_dir, "CMakeCache.txt")
|
46
44
|
assert File.exist?(cmakecache), cmakecache
|
47
45
|
|
@@ -49,16 +47,215 @@ class TestCMake < TestCase
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def test_compile
|
52
|
-
|
53
|
-
|
54
|
-
binary = File.join(work_dir, "hello")
|
50
|
+
binary = File.join(work_dir, exe_name)
|
55
51
|
assert File.exist?(binary), binary
|
56
52
|
end
|
57
53
|
|
58
54
|
def test_install
|
59
|
-
|
60
|
-
|
61
|
-
binary = File.join(recipe.path, "bin", "hello")
|
55
|
+
binary = File.join(recipe.path, "bin", exe_name)
|
62
56
|
assert File.exist?(binary), binary
|
63
57
|
end
|
58
|
+
|
59
|
+
def init_recipe
|
60
|
+
MiniPortileCMake.new("test-cmake", "1.0").tap do |recipe|
|
61
|
+
recipe.files << "http://localhost:#{HTTP_PORT}/#{ERB::Util.url_encode(File.basename(@tar_path))}"
|
62
|
+
recipe.patch_files << File.join(@assets_path, "patch 1.diff")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class TestCMakeConfig < TestCMake
|
68
|
+
def test_make_command_configuration
|
69
|
+
MiniPortile.stub(:mswin?, false) do
|
70
|
+
without_env("MAKE") do
|
71
|
+
assert_equal("make", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
72
|
+
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
73
|
+
end
|
74
|
+
with_env("MAKE"=>"asdf") do
|
75
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
76
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
MiniPortile.stub(:mswin?, true) do
|
81
|
+
assert_equal("nmake", MiniPortileCMake.new("test", "1.0.0").make_cmd)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_configure_defaults_with_macos
|
86
|
+
recipe = init_recipe
|
87
|
+
recipe.host = 'some-host'
|
88
|
+
|
89
|
+
with_env({ "CC" => nil, "CXX" => nil }) do
|
90
|
+
MiniPortile.stub(:darwin?, true) do
|
91
|
+
with_stubbed_target(os: 'darwin22', cpu: 'arm64') do
|
92
|
+
with_compilers(recipe, host_prefix: true, c_compiler: 'clang', cxx_compiler: 'clang++') do
|
93
|
+
Open3.stub(:capture2, cmake_help_mock('Unix')) do
|
94
|
+
assert_equal(
|
95
|
+
[
|
96
|
+
"-DCMAKE_SYSTEM_NAME=Darwin",
|
97
|
+
"-DCMAKE_SYSTEM_PROCESSOR=arm64",
|
98
|
+
"-DCMAKE_C_COMPILER=some-host-clang",
|
99
|
+
"-DCMAKE_CXX_COMPILER=some-host-clang++",
|
100
|
+
"-DCMAKE_BUILD_TYPE=Release"
|
101
|
+
],
|
102
|
+
recipe.configure_defaults)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_configure_defaults_with_manual_system_name
|
111
|
+
recipe = init_recipe
|
112
|
+
recipe.system_name = 'Custom'
|
113
|
+
|
114
|
+
MiniPortile.stub(:darwin?, false) do
|
115
|
+
with_stubbed_target do
|
116
|
+
with_compilers(recipe) do
|
117
|
+
Open3.stub(:capture2, cmake_help_mock('Unix')) do
|
118
|
+
assert_equal(
|
119
|
+
[
|
120
|
+
"-DCMAKE_SYSTEM_NAME=Custom",
|
121
|
+
"-DCMAKE_SYSTEM_PROCESSOR=x86_64",
|
122
|
+
"-DCMAKE_C_COMPILER=gcc",
|
123
|
+
"-DCMAKE_CXX_COMPILER=g++",
|
124
|
+
"-DCMAKE_BUILD_TYPE=Release"
|
125
|
+
],
|
126
|
+
recipe.configure_defaults)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_configure_defaults_with_unix_makefiles
|
134
|
+
recipe = init_recipe
|
135
|
+
|
136
|
+
MiniPortile.stub(:linux?, true) do
|
137
|
+
MiniPortile.stub(:darwin?, false) do
|
138
|
+
with_stubbed_target do
|
139
|
+
with_compilers(recipe) do
|
140
|
+
Open3.stub(:capture2, cmake_help_mock('Unix')) do
|
141
|
+
MiniPortile.stub(:mingw?, true) do
|
142
|
+
assert_equal(default_x86_compile_flags,
|
143
|
+
recipe.configure_defaults)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_configure_defaults_with_msys_makefiles
|
153
|
+
recipe = init_recipe
|
154
|
+
|
155
|
+
MiniPortile.stub(:linux?, true) do
|
156
|
+
MiniPortile.stub(:darwin?, false) do
|
157
|
+
with_stubbed_target do
|
158
|
+
with_compilers(recipe) do
|
159
|
+
Open3.stub(:capture2, cmake_help_mock('MSYS')) do
|
160
|
+
MiniPortile.stub(:mingw?, true) do
|
161
|
+
assert_equal(['-G', 'MSYS Makefiles'] + default_x86_compile_flags, recipe.configure_defaults)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_configure_defaults_with_nmake_makefiles
|
171
|
+
recipe = init_recipe
|
172
|
+
|
173
|
+
MiniPortile.stub(:linux?, true) do
|
174
|
+
MiniPortile.stub(:darwin?, false) do
|
175
|
+
with_stubbed_target do
|
176
|
+
with_compilers(recipe) do
|
177
|
+
Open3.stub(:capture2, cmake_help_mock('NMake')) do
|
178
|
+
MiniPortile.stub(:mswin?, true) do
|
179
|
+
assert_equal(['-G', 'NMake Makefiles'] + default_x86_compile_flags, recipe.configure_defaults)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_cmake_command_configuration
|
189
|
+
without_env("CMAKE") do
|
190
|
+
assert_equal("cmake", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
|
191
|
+
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
|
192
|
+
end
|
193
|
+
with_env("CMAKE"=>"asdf") do
|
194
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0").cmake_cmd)
|
195
|
+
assert_equal("asdf", MiniPortileCMake.new("test", "1.0.0", cmake_command: "xyzzy").cmake_cmd)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_cmake_build_type_configuration
|
200
|
+
without_env("CMAKE_BUILD_TYPE") do
|
201
|
+
assert_equal("Release", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
|
202
|
+
assert_equal("xyzzy", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
|
203
|
+
end
|
204
|
+
with_env("CMAKE_BUILD_TYPE"=>"Debug") do
|
205
|
+
assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0").cmake_build_type)
|
206
|
+
assert_equal("Debug", MiniPortileCMake.new("test", "1.0.0", cmake_build_type: "xyzzy").cmake_build_type)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
private
|
211
|
+
|
212
|
+
def with_stubbed_target(os: 'linux', cpu: 'x86_64')
|
213
|
+
MiniPortile.stub(:target_os, os) do
|
214
|
+
MiniPortile.stub(:target_cpu, cpu) do
|
215
|
+
yield
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def with_compilers(recipe, host_prefix: false, c_compiler: 'gcc', cxx_compiler: 'g++')
|
221
|
+
mock = MiniTest::Mock.new
|
222
|
+
|
223
|
+
if host_prefix
|
224
|
+
mock.expect(:call, true, ["#{recipe.host}-#{c_compiler}"])
|
225
|
+
mock.expect(:call, true, ["#{recipe.host}-#{cxx_compiler}"])
|
226
|
+
else
|
227
|
+
mock.expect(:call, false, ["#{recipe.host}-#{c_compiler}"])
|
228
|
+
mock.expect(:call, true, [c_compiler])
|
229
|
+
mock.expect(:call, false, ["#{recipe.host}-#{cxx_compiler}"])
|
230
|
+
mock.expect(:call, true, [cxx_compiler])
|
231
|
+
end
|
232
|
+
|
233
|
+
recipe.stub(:which, mock) do
|
234
|
+
yield
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def default_x86_compile_flags
|
239
|
+
[
|
240
|
+
"-DCMAKE_SYSTEM_NAME=Linux",
|
241
|
+
"-DCMAKE_SYSTEM_PROCESSOR=x86_64",
|
242
|
+
"-DCMAKE_C_COMPILER=gcc",
|
243
|
+
"-DCMAKE_CXX_COMPILER=g++",
|
244
|
+
"-DCMAKE_BUILD_TYPE=Release"
|
245
|
+
]
|
246
|
+
end
|
247
|
+
|
248
|
+
def cmake_help_mock(generator_type)
|
249
|
+
open3_mock = MiniTest::Mock.new
|
250
|
+
cmake_script = <<~SCRIPT
|
251
|
+
echo "The following generators are available on this platform (* marks default):"
|
252
|
+
echo "* #{generator_type} Makefiles = Generates standard #{generator_type.upcase} makefiles."
|
253
|
+
SCRIPT
|
254
|
+
|
255
|
+
exit_status = MiniTest::Mock.new
|
256
|
+
exit_status.expect(:success?, true)
|
257
|
+
expected_output = [cmake_script, exit_status]
|
258
|
+
open3_mock.expect(:call, expected_output, ['cmake --help'])
|
259
|
+
open3_mock
|
260
|
+
end
|
64
261
|
end
|
data/test/test_cook.rb
CHANGED
@@ -67,6 +67,32 @@ class TestCook < TestCase
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
class TestCookConfiguration < TestCase
|
71
|
+
def test_make_command_configuration
|
72
|
+
without_env("MAKE") do
|
73
|
+
assert_equal("make", MiniPortile.new("test", "1.0.0").make_cmd)
|
74
|
+
assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
75
|
+
end
|
76
|
+
with_env("MAKE"=>"asdf") do
|
77
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0").make_cmd)
|
78
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0", make_command: "xyzzy").make_cmd)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_gcc_command_configuration
|
83
|
+
without_env("CC") do
|
84
|
+
expected_compiler = RbConfig::CONFIG["CC"] || "gcc"
|
85
|
+
assert_equal(expected_compiler, MiniPortile.new("test", "1.0.0").gcc_cmd)
|
86
|
+
assert_equal("xyzzy", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
|
87
|
+
end
|
88
|
+
with_env("CC"=>"asdf") do
|
89
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0").gcc_cmd)
|
90
|
+
assert_equal("asdf", MiniPortile.new("test", "1.0.0", gcc_command: "xyzzy").gcc_cmd)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
70
96
|
class TestCookWithBrokenGitDir < TestCase
|
71
97
|
#
|
72
98
|
# this is a test for #69
|
@@ -113,3 +139,32 @@ class TestCookWithBrokenGitDir < TestCase
|
|
113
139
|
end
|
114
140
|
end
|
115
141
|
end
|
142
|
+
|
143
|
+
class TestCookAgainstSourceDirectory < TestCase
|
144
|
+
attr_accessor :recipe
|
145
|
+
|
146
|
+
def setup
|
147
|
+
super
|
148
|
+
|
149
|
+
@recipe ||= MiniPortile.new("test mini portile", "1.0.0").tap do |recipe|
|
150
|
+
recipe.source_directory = File.expand_path("../assets/test mini portile-1.0.0", __FILE__)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_source_directory
|
155
|
+
recipe.cook
|
156
|
+
|
157
|
+
path = File.join(work_dir, "configure.txt")
|
158
|
+
assert(File.exist?(path))
|
159
|
+
assert_equal((recipe.configure_options + ["--prefix=#{recipe.path}"]).inspect,
|
160
|
+
File.read(path).chomp);
|
161
|
+
|
162
|
+
path = File.join(work_dir, "compile.txt")
|
163
|
+
assert(File.exist?(path))
|
164
|
+
assert_equal("[\"all\"]", File.read(path).chomp);
|
165
|
+
|
166
|
+
path = File.join(work_dir, "install.txt")
|
167
|
+
assert(File.exist?(path))
|
168
|
+
assert_equal("[\"install\"]", File.read(path).chomp);
|
169
|
+
end
|
170
|
+
end
|
data/test/test_download.rb
CHANGED
@@ -18,10 +18,12 @@ describe "recipe download" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
begin
|
22
|
+
block.call
|
23
|
+
ensure
|
24
|
+
thread.kill
|
25
|
+
server.close
|
26
|
+
end
|
25
27
|
|
26
28
|
request_count.must_be :>, 0
|
27
29
|
end
|
@@ -60,7 +62,7 @@ describe "recipe download" do
|
|
60
62
|
@recipe.files << "file://#{path}"
|
61
63
|
@recipe.download
|
62
64
|
assert File.exist?(dest)
|
63
|
-
Digest::MD5.file(dest).hexdigest.must_equal "
|
65
|
+
Digest::MD5.file(dest).hexdigest.must_equal "ee0e9f44e72213015ef976d5ac23931d"
|
64
66
|
end
|
65
67
|
|
66
68
|
it "other" do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
|
3
|
+
class TestExecute < TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@env = {"TEST_ENV_VAR1" => "VAR1_VALUE", "TEST_ENV_VAR2" => "VAR2_VALUE"}
|
7
|
+
@recipe = MiniPortile.new("test_execute", "1.0.0")
|
8
|
+
@log_path = @recipe.send(:tmp_path)
|
9
|
+
FileUtils.mkdir_p File.join(@log_path, "subdir") # normally created by `download`
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_execute_one_big_string_arg
|
13
|
+
class << @recipe
|
14
|
+
def execute_with_env(env)
|
15
|
+
execute("testenv1",
|
16
|
+
%Q(ruby -e "puts ENV['TEST_ENV_VAR1'].inspect ; exit 0"),
|
17
|
+
{:env => env, :initial_message => false, :debug => true})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@recipe.execute_with_env(@env)
|
22
|
+
|
23
|
+
assert_equal("VAR1_VALUE".inspect, IO.read(File.join(@log_path, "testenv1.log")).chomp)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_execute_array_args
|
27
|
+
class << @recipe
|
28
|
+
def execute_with_env(env)
|
29
|
+
execute("testenv2",
|
30
|
+
["ruby", "-e", "puts ENV['TEST_ENV_VAR2'].inspect"],
|
31
|
+
{:env => env, :initial_message => false, :debug => true})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
@recipe.execute_with_env(@env)
|
36
|
+
|
37
|
+
assert_equal("VAR2_VALUE".inspect, IO.read(File.join(@log_path, "testenv2.log")).chomp)
|
38
|
+
end
|
39
|
+
end
|