thermite 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +3 -1
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/NEWS.md +10 -0
- data/README.md +9 -1
- data/lib/thermite/config.rb +18 -0
- data/lib/thermite/custom_binary.rb +65 -0
- data/lib/thermite/github_release_binary.rb +11 -23
- data/lib/thermite/package.rb +14 -4
- data/lib/thermite/tasks.rb +10 -1
- data/lib/thermite/util.rb +23 -0
- data/test/lib/thermite/custom_binary_test.rb +39 -0
- data/test/lib/thermite/github_release_binary_test.rb +11 -11
- data/test/lib/thermite/package_test.rb +16 -7
- data/test/test_helper.rb +6 -11
- data/thermite.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9902385f6d7c70426db6c25fabe306a29034e7fc
|
4
|
+
data.tar.gz: 4618e00a6dfb06afef4ab73675b9f45bdf892b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68aa59bb0dc5129afc1cd63d56ccf6e10de7ea30199dddda075edcc2d3320563ab6a0dc73ef86862cbd49e02664e07cc90ce3060ffa115f635124a8c0eddb708
|
7
|
+
data.tar.gz: 0391dce454f1da154121078fb9edf3ffbadecc11294e443a2dbcf09ec2a7a2056e366cf61ec6a54b6ed7e80ed323cd23236b9dfcbc55a0427d211a2270b0c9c2
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -22,7 +22,7 @@ When filing a bug, please include the following information:
|
|
22
22
|
* If it's an error related to Rust, the version of Rust, Cargo, and how you installed it.
|
23
23
|
* A detailed list of steps to reproduce the bug. A minimal testcase would be very helpful,
|
24
24
|
if possible.
|
25
|
-
* If there
|
25
|
+
* If there are any error messages in the console, copying them in the bug summary will be
|
26
26
|
very helpful.
|
27
27
|
|
28
28
|
## Filing Pull Requests
|
data/Gemfile
CHANGED
data/NEWS.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## [0.8.0] - 2016-12-05
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
* Support for binary download URIs from non-GitHub sources (#17)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
* Tarballs are installed relative to `ruby_project_path`
|
14
|
+
|
5
15
|
## [0.7.0] - 2016-09-26
|
6
16
|
|
7
17
|
### Added
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@ Thermite is a Rake-based helper for building and distributing Rust-based Ruby ex
|
|
14
14
|
* Provides wrappers for `cargo` commands.
|
15
15
|
* Handles non-standard `cargo` installations via the `CARGO` environment variable.
|
16
16
|
* Opt-in to allow users to install pre-compiled Rust extensions hosted on GitHub releases.
|
17
|
+
* Opt-in to allow users to install pre-compiled Rust extensions hosted on a third party server.
|
17
18
|
* Provides a wrapper for initializing a Rust extension via Fiddle.
|
18
19
|
|
19
20
|
## Usage
|
@@ -49,7 +50,7 @@ Thermite is a Rake-based helper for building and distributing Rust-based Ruby ex
|
|
49
50
|
end
|
50
51
|
```
|
51
52
|
|
52
|
-
Run `rake -T` to view all of the available tasks in the `thermite` namespace.
|
53
|
+
Run `rake -T thermite` to view all of the available tasks in the `thermite` namespace.
|
53
54
|
|
54
55
|
### Configuration
|
55
56
|
|
@@ -68,6 +69,13 @@ github_releases = true
|
|
68
69
|
|
69
70
|
Possible options:
|
70
71
|
|
72
|
+
* `binary_uri_format` - if set, the interpolation-formatted string used to construct the download
|
73
|
+
URI for the pre-built native extension. If the environment variable `THERMITE_BINARY_URI_FORMAT`
|
74
|
+
is set, it takes precedence over this option. Either method of setting this option overrides the
|
75
|
+
`github_releases` option.
|
76
|
+
Example: `https://example.com/download/%{version}/%{filename}`. Replacement variables:
|
77
|
+
- `filename` - The value of `Config.tarball_filename`
|
78
|
+
- `version` - the crate version from `Cargo.toml`
|
71
79
|
* `cargo_project_path` - the path to the Cargo project. Defaults to the current working directory.
|
72
80
|
* `github_releases` - whether to look for Rust binaries via GitHub releases when installing
|
73
81
|
the gem, and `cargo` is not found. Defaults to `false`.
|
data/lib/thermite/config.rb
CHANGED
@@ -58,6 +58,17 @@ module Thermite
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
#
|
62
|
+
# The interpolation-formatted string used to construct the download URI for the pre-built
|
63
|
+
# native extension. Can be set via the `THERMITE_BINARY_URI_FORMAT` environment variable, or a
|
64
|
+
# `binary_uri_format` option.
|
65
|
+
#
|
66
|
+
def binary_uri_format
|
67
|
+
@binary_uri_format ||= ENV['THERMITE_BINARY_URI_FORMAT'] ||
|
68
|
+
@options[:binary_uri_format] ||
|
69
|
+
false
|
70
|
+
end
|
71
|
+
|
61
72
|
#
|
62
73
|
# The major and minor version of the Ruby interpreter that's currently running.
|
63
74
|
#
|
@@ -180,6 +191,13 @@ module Thermite
|
|
180
191
|
@toml ||= Tomlrb.load_file(rust_path('Cargo.toml'), symbolize_keys: true)
|
181
192
|
end
|
182
193
|
|
194
|
+
#
|
195
|
+
# Alias to the crate version specified in the TOML file.
|
196
|
+
#
|
197
|
+
def crate_version
|
198
|
+
toml[:package][:version]
|
199
|
+
end
|
200
|
+
|
183
201
|
#
|
184
202
|
# The Thermite-specific config from the TOML file.
|
185
203
|
#
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# Copyright (c) 2016 Mark Lee and contributors
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
7
|
+
# associated documentation files (the "Software"), to deal in the Software without restriction,
|
8
|
+
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
9
|
+
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all copies or
|
13
|
+
# substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
16
|
+
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
19
|
+
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'net/http'
|
22
|
+
require 'uri'
|
23
|
+
|
24
|
+
module Thermite
|
25
|
+
#
|
26
|
+
# Custom binary URI helpers.
|
27
|
+
#
|
28
|
+
module CustomBinary
|
29
|
+
#
|
30
|
+
# Downloads a Rust binary using a custom URI format, given the target OS and architecture.
|
31
|
+
#
|
32
|
+
# Requires the `binary_uri_format` option to be set. The version of the binary is determined by
|
33
|
+
# the crate version given in `Cargo.toml`.
|
34
|
+
#
|
35
|
+
# Returns whether a binary was found and unpacked.
|
36
|
+
#
|
37
|
+
def download_binary_from_custom_uri
|
38
|
+
return false unless config.binary_uri_format
|
39
|
+
|
40
|
+
version = config.crate_version
|
41
|
+
uri ||= config.binary_uri_format % {
|
42
|
+
filename: config.tarball_filename(version),
|
43
|
+
version: version
|
44
|
+
}
|
45
|
+
|
46
|
+
return false unless (tgz = download_versioned_binary(uri, version))
|
47
|
+
|
48
|
+
debug "Unpacking binary from Cargo version: #{File.basename(uri)}"
|
49
|
+
unpack_tarball(tgz)
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def download_versioned_binary(uri, version)
|
56
|
+
unless ENV.key?('THERMITE_TEST')
|
57
|
+
# :nocov:
|
58
|
+
puts "Downloading compiled version (#{version})"
|
59
|
+
# :nocov:
|
60
|
+
end
|
61
|
+
|
62
|
+
http_get(uri)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -40,7 +40,7 @@ module Thermite
|
|
40
40
|
#
|
41
41
|
# Returns whether a binary was found and unpacked.
|
42
42
|
#
|
43
|
-
def
|
43
|
+
def download_binary_from_github_release
|
44
44
|
return false unless options[:github_releases]
|
45
45
|
|
46
46
|
case options[:github_release_type]
|
@@ -54,10 +54,10 @@ module Thermite
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def download_cargo_version_from_github_release
|
57
|
-
version = config.
|
57
|
+
version = config.crate_version
|
58
58
|
tag = options.fetch(:git_tag_format, 'v%s') % version
|
59
59
|
uri = github_download_uri(tag, version)
|
60
|
-
return unless (tgz =
|
60
|
+
return false unless (tgz = download_versioned_github_release_binary(uri, version))
|
61
61
|
|
62
62
|
debug "Unpacking GitHub release from Cargo version: #{File.basename(uri)}"
|
63
63
|
unpack_tarball(tgz)
|
@@ -71,7 +71,7 @@ module Thermite
|
|
71
71
|
def download_latest_binary_from_github_release
|
72
72
|
installed_binary = false
|
73
73
|
each_github_release(github_uri) do |version, download_uri|
|
74
|
-
tgz =
|
74
|
+
tgz = download_versioned_github_release_binary(download_uri, version)
|
75
75
|
next unless tgz
|
76
76
|
debug "Unpacking GitHub release: #{File.basename(download_uri)}"
|
77
77
|
unpack_tarball(tgz)
|
@@ -90,12 +90,6 @@ module Thermite
|
|
90
90
|
"#{github_uri}/releases/download/#{tag}/#{config.tarball_filename(version)}"
|
91
91
|
end
|
92
92
|
|
93
|
-
# :nocov:
|
94
|
-
def http_get(uri)
|
95
|
-
Net::HTTP.get(URI(uri))
|
96
|
-
end
|
97
|
-
# :nocov:
|
98
|
-
|
99
93
|
def each_github_release(github_uri)
|
100
94
|
releases_uri = "#{github_uri}/releases.atom"
|
101
95
|
feed = REXML::Document.new(http_get(releases_uri))
|
@@ -108,20 +102,14 @@ module Thermite
|
|
108
102
|
end
|
109
103
|
end
|
110
104
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
raise Net::HTTPServerException.new(response.message, response)
|
117
|
-
else
|
118
|
-
unless ENV.key?('THERMITE_TEST')
|
119
|
-
# :nocov:
|
120
|
-
puts "Downloading latest compiled version (#{version}) from GitHub"
|
121
|
-
# :nocov:
|
122
|
-
end
|
123
|
-
StringIO.new(http_get(response['location']))
|
105
|
+
def download_versioned_github_release_binary(uri, version)
|
106
|
+
unless ENV.key?('THERMITE_TEST')
|
107
|
+
# :nocov:
|
108
|
+
puts "Downloading compiled version (#{version}) from GitHub"
|
109
|
+
# :nocov:
|
124
110
|
end
|
111
|
+
|
112
|
+
http_get(uri)
|
125
113
|
end
|
126
114
|
end
|
127
115
|
end
|
data/lib/thermite/package.rb
CHANGED
@@ -45,15 +45,25 @@ module Thermite
|
|
45
45
|
# working directory.
|
46
46
|
#
|
47
47
|
def unpack_tarball(tgz)
|
48
|
+
Dir.chdir(config.ruby_toplevel_dir) do
|
49
|
+
each_compressed_file(tgz) do |path, entry|
|
50
|
+
debug "Unpacking file: #{path}"
|
51
|
+
File.open(path, 'wb') do |f|
|
52
|
+
f.write(entry.read)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def each_compressed_file(tgz)
|
48
61
|
Zlib::GzipReader.wrap(tgz) do |gz|
|
49
62
|
Gem::Package::TarReader.new(gz) do |tar|
|
50
63
|
tar.each do |entry|
|
51
64
|
path = entry.header.name
|
52
65
|
next if path.end_with?('/')
|
53
|
-
|
54
|
-
File.open(path, 'wb') do |f|
|
55
|
-
f.write(entry.read)
|
56
|
-
end
|
66
|
+
yield path, entry
|
57
67
|
end
|
58
68
|
end
|
59
69
|
end
|
data/lib/thermite/tasks.rb
CHANGED
@@ -22,6 +22,7 @@ require 'fileutils'
|
|
22
22
|
require 'rake/tasklib'
|
23
23
|
require 'thermite/cargo'
|
24
24
|
require 'thermite/config'
|
25
|
+
require 'thermite/custom_binary'
|
25
26
|
require 'thermite/github_release_binary'
|
26
27
|
require 'thermite/package'
|
27
28
|
require 'thermite/util'
|
@@ -40,6 +41,7 @@ module Thermite
|
|
40
41
|
#
|
41
42
|
class Tasks < Rake::TaskLib
|
42
43
|
include Thermite::Cargo
|
44
|
+
include Thermite::CustomBinary
|
43
45
|
include Thermite::GithubReleaseBinary
|
44
46
|
include Thermite::Package
|
45
47
|
include Thermite::Util
|
@@ -52,6 +54,13 @@ module Thermite
|
|
52
54
|
#
|
53
55
|
# Possible configuration options for Thermite tasks:
|
54
56
|
#
|
57
|
+
# * `binary_uri_format` - if set, the interpolation-formatted string used to construct the
|
58
|
+
# download URI for the pre-built native extension. If the environment variable
|
59
|
+
# `THERMITE_BINARY_URI_FORMAT` is set, it takes precedence over this option. Either method of
|
60
|
+
# setting this option overrides the `github_releases` option.
|
61
|
+
# Example: `https://example.com/download/%{version}/%{filename}`. Replacement variables:
|
62
|
+
# - `filename` - The value of {Config#tarball_filename}
|
63
|
+
# - `version` - the crate version from the `Cargo.toml` file
|
55
64
|
# * `cargo_project_path` - the path to the Cargo project. Defaults to the current
|
56
65
|
# working directory.
|
57
66
|
# * `github_releases` - whether to look for rust binaries via GitHub releases when installing
|
@@ -112,7 +121,7 @@ module Thermite
|
|
112
121
|
run_cargo_build(target)
|
113
122
|
FileUtils.cp(config.rust_path('target', target, config.shared_library),
|
114
123
|
config.ruby_path('lib'))
|
115
|
-
elsif !
|
124
|
+
elsif !download_binary_from_custom_uri && !download_binary_from_github_release
|
116
125
|
inform_user_about_cargo
|
117
126
|
end
|
118
127
|
end
|
data/lib/thermite/util.rb
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
19
19
|
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
20
|
|
21
|
+
require 'net/http'
|
22
|
+
|
21
23
|
module Thermite
|
22
24
|
#
|
23
25
|
# Utility methods
|
@@ -32,6 +34,27 @@ module Thermite
|
|
32
34
|
|
33
35
|
@debug ||= File.open(config.debug_filename, 'w')
|
34
36
|
@debug.write("#{msg}\n")
|
37
|
+
@debug.flush
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Wrapper for a Net::HTTP GET request that handles redirects.
|
42
|
+
#
|
43
|
+
# :nocov:
|
44
|
+
def http_get(uri, retries_left = 10)
|
45
|
+
raise RedirectError, 'Too many redirects' if retries_left.zero?
|
46
|
+
|
47
|
+
case (response = Net::HTTP.get_response(URI(uri)))
|
48
|
+
when Net::HTTPClientError
|
49
|
+
nil
|
50
|
+
when Net::HTTPServerError
|
51
|
+
raise Net::HTTPServerException.new(response.message, response)
|
52
|
+
when Net::HTTPFound, Net::HTTPPermanentRedirect
|
53
|
+
http_get(response['location'], retries_left - 1)
|
54
|
+
else
|
55
|
+
StringIO.new(response.body)
|
56
|
+
end
|
35
57
|
end
|
58
|
+
# :nocov:
|
36
59
|
end
|
37
60
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'test_helper'
|
3
|
+
require 'thermite/custom_binary'
|
4
|
+
require 'thermite/util'
|
5
|
+
|
6
|
+
module Thermite
|
7
|
+
class CustomBinaryTest < Minitest::Test
|
8
|
+
include Thermite::ModuleTester
|
9
|
+
|
10
|
+
class Tester
|
11
|
+
include Thermite::CustomBinary
|
12
|
+
include Thermite::TestHelper
|
13
|
+
include Thermite::Util
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_no_downloading_when_binary_uri_is_falsey
|
17
|
+
mock_module(binary_uri_format: false)
|
18
|
+
mock_module.expects(:http_get).never
|
19
|
+
|
20
|
+
assert !mock_module.download_binary_from_custom_uri
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_download_binary_from_custom_uri
|
24
|
+
mock_module(binary_uri_format: 'http://example.com/download/%{version}/%{filename}')
|
25
|
+
mock_module.config.stubs(:toml).returns(package: { version: '4.5.6' })
|
26
|
+
Net::HTTP.stubs(:get_response).returns('location' => 'redirect')
|
27
|
+
mock_module.stubs(:http_get).returns('tarball')
|
28
|
+
mock_module.expects(:unpack_tarball).once
|
29
|
+
|
30
|
+
assert mock_module.download_binary_from_custom_uri
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def described_class
|
36
|
+
Tester
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -18,7 +18,7 @@ module Thermite
|
|
18
18
|
mock_module.expects(:download_latest_binary_from_github_release).never
|
19
19
|
mock_module.expects(:download_cargo_version_from_github_release).never
|
20
20
|
|
21
|
-
assert !mock_module.
|
21
|
+
assert !mock_module.download_binary_from_github_release
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_github_release_type_defaults_to_cargo
|
@@ -26,7 +26,7 @@ module Thermite
|
|
26
26
|
mock_module.expects(:download_latest_binary_from_github_release).never
|
27
27
|
mock_module.expects(:download_cargo_version_from_github_release).once
|
28
28
|
|
29
|
-
mock_module.
|
29
|
+
mock_module.download_binary_from_github_release
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_download_cargo_version_from_github_release
|
@@ -37,7 +37,7 @@ module Thermite
|
|
37
37
|
mock_module.stubs(:http_get).returns('tarball')
|
38
38
|
mock_module.expects(:unpack_tarball).once
|
39
39
|
|
40
|
-
assert mock_module.
|
40
|
+
assert mock_module.download_binary_from_github_release
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_download_cargo_version_from_github_release_with_custom_git_tag_format
|
@@ -48,7 +48,7 @@ module Thermite
|
|
48
48
|
mock_module.stubs(:http_get).returns('tarball')
|
49
49
|
mock_module.expects(:unpack_tarball).once
|
50
50
|
|
51
|
-
assert mock_module.
|
51
|
+
assert mock_module.download_binary_from_github_release
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_download_cargo_version_from_github_release_with_client_error
|
@@ -56,7 +56,7 @@ module Thermite
|
|
56
56
|
mock_module.config.stubs(:toml).returns(package: { version: '4.5.6' })
|
57
57
|
Net::HTTP.stubs(:get_response).returns(Net::HTTPClientError.new('1.1', 403, 'Forbidden'))
|
58
58
|
|
59
|
-
assert !mock_module.
|
59
|
+
assert !mock_module.download_binary_from_github_release
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_download_cargo_version_from_github_release_with_server_error
|
@@ -66,17 +66,17 @@ module Thermite
|
|
66
66
|
Net::HTTP.stubs(:get_response).returns(server_error)
|
67
67
|
|
68
68
|
assert_raises Net::HTTPServerException do
|
69
|
-
mock_module.
|
69
|
+
mock_module.download_binary_from_github_release
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_download_latest_binary_from_github_release
|
74
74
|
mock_module(github_releases: true, github_release_type: 'latest', git_tag_regex: 'v(.*)-rust')
|
75
75
|
stub_releases_atom
|
76
|
-
mock_module.stubs(:
|
76
|
+
mock_module.stubs(:download_versioned_github_release_binary).returns(StringIO.new('tarball'))
|
77
77
|
mock_module.expects(:unpack_tarball).once
|
78
78
|
|
79
|
-
assert mock_module.
|
79
|
+
assert mock_module.download_binary_from_github_release
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_download_latest_binary_from_github_release_no_releases_match_regex
|
@@ -84,16 +84,16 @@ module Thermite
|
|
84
84
|
stub_releases_atom
|
85
85
|
mock_module.expects(:github_download_uri).never
|
86
86
|
|
87
|
-
assert !mock_module.
|
87
|
+
assert !mock_module.download_binary_from_github_release
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_download_latest_binary_from_github_release_no_tarball_found
|
91
91
|
mock_module(github_releases: true, github_release_type: 'latest', git_tag_regex: 'v(.*)-rust')
|
92
92
|
stub_releases_atom
|
93
|
-
mock_module.stubs(:
|
93
|
+
mock_module.stubs(:download_versioned_github_release_binary).returns(nil)
|
94
94
|
mock_module.expects(:unpack_tarball).never
|
95
95
|
|
96
|
-
assert !mock_module.
|
96
|
+
assert !mock_module.download_binary_from_github_release
|
97
97
|
end
|
98
98
|
|
99
99
|
private
|
@@ -21,15 +21,18 @@ module Thermite
|
|
21
21
|
stub_config(project_dir, extension_path, tgz_filename)
|
22
22
|
|
23
23
|
mock_module.build_package
|
24
|
-
|
24
|
+
FileUtils.rm_f(extension_path)
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
# This simulates having an extension build via `install/Rakefile` instead of the
|
27
|
+
# top-level Rakefile.
|
28
|
+
using_install_dir(stub_dir(dir, 'install')) do
|
29
|
+
assert_file_created(extension_path) do
|
30
|
+
File.open(tgz_filename, 'rb') do |f|
|
31
|
+
mock_module.unpack_tarball(f)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
assert_equal 'some extension', File.read(extension_path)
|
29
35
|
end
|
30
|
-
packed_file = File.join(install_dir, 'lib', 'test.txt')
|
31
|
-
assert File.exist?(packed_file), "File '#{packed_file}' does not exist."
|
32
|
-
assert_equal 'some extension', File.read(packed_file)
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -87,5 +90,11 @@ module Thermite
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
end
|
93
|
+
|
94
|
+
def assert_file_created(filename)
|
95
|
+
refute File.exist?(filename), "File '#{filename}' already exists."
|
96
|
+
yield
|
97
|
+
assert File.exist?(filename), "File '#{filename}' does not exist."
|
98
|
+
end
|
90
99
|
end
|
91
100
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
load_profile 'test_frameworks'
|
8
|
-
add_filter 'lib/thermite/fiddle.rb'
|
9
|
-
add_filter 'lib/thermite/tasks.rb'
|
10
|
-
track_files 'lib/**/*.rb'
|
11
|
-
end
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
load_profile 'test_frameworks'
|
4
|
+
add_filter 'lib/thermite/fiddle.rb'
|
5
|
+
add_filter 'lib/thermite/tasks.rb'
|
6
|
+
track_files 'lib/**/*.rb'
|
12
7
|
end
|
13
8
|
|
14
9
|
ENV['THERMITE_TEST'] = '1'
|
data/thermite.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thermite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- ci/after_success.py
|
129
129
|
- lib/thermite/cargo.rb
|
130
130
|
- lib/thermite/config.rb
|
131
|
+
- lib/thermite/custom_binary.rb
|
131
132
|
- lib/thermite/fiddle.rb
|
132
133
|
- lib/thermite/github_release_binary.rb
|
133
134
|
- lib/thermite/package.rb
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- test/fixtures/github/releases.atom
|
138
139
|
- test/lib/thermite/cargo_test.rb
|
139
140
|
- test/lib/thermite/config_test.rb
|
141
|
+
- test/lib/thermite/custom_binary_test.rb
|
140
142
|
- test/lib/thermite/github_release_binary_test.rb
|
141
143
|
- test/lib/thermite/package_test.rb
|
142
144
|
- test/lib/thermite/util_test.rb
|