buildpack-support 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +202 -0
- data/NOTICE +2 -0
- data/docs/cache.md +77 -0
- data/docs/component.md +1 -0
- data/docs/configuration.md +27 -0
- data/docs/logging.md +54 -0
- data/docs/other.md +1 -0
- data/docs/rake.md +1 -0
- data/docs/repository.md +116 -0
- data/docs/test.md +1 -0
- data/lib/buildpack_support.rb +18 -0
- data/lib/buildpack_support/base_buildpack.rb +166 -0
- data/lib/buildpack_support/buildpack_version.rb +124 -0
- data/lib/buildpack_support/cache.rb +24 -0
- data/lib/buildpack_support/cache/application_cache.rb +41 -0
- data/lib/buildpack_support/cache/cached_file.rb +103 -0
- data/lib/buildpack_support/cache/download_cache.rb +280 -0
- data/lib/buildpack_support/cache/inferred_network_failure.rb +26 -0
- data/lib/buildpack_support/cache/internet_availability.rb +64 -0
- data/lib/buildpack_support/component.rb +24 -0
- data/lib/buildpack_support/component/application.rb +76 -0
- data/lib/buildpack_support/component/base_component.rb +78 -0
- data/lib/buildpack_support/component/base_droplet.rb +96 -0
- data/lib/buildpack_support/component/downloads.rb +88 -0
- data/lib/buildpack_support/component/services.rb +84 -0
- data/lib/buildpack_support/component/versioned_dependency_component.rb +71 -0
- data/lib/buildpack_support/component/versioned_downloads.rb +57 -0
- data/lib/buildpack_support/component/with_timing.rb +40 -0
- data/lib/buildpack_support/configuration_utils.rb +58 -0
- data/lib/buildpack_support/constantize.rb +46 -0
- data/lib/buildpack_support/dash_case.rb +29 -0
- data/lib/buildpack_support/directory_finder.rb +45 -0
- data/lib/buildpack_support/filtering_pathname.rb +227 -0
- data/lib/buildpack_support/format_duration.rb +57 -0
- data/lib/buildpack_support/logging.rb +22 -0
- data/lib/buildpack_support/logging/delegating_logger.rb +48 -0
- data/lib/buildpack_support/logging/logger_factory.rb +148 -0
- data/lib/buildpack_support/qualify_path.rb +36 -0
- data/lib/buildpack_support/rake.rb +22 -0
- data/lib/buildpack_support/rake/buildpack_stage_task.rb +86 -0
- data/lib/buildpack_support/rake/cached_artifact_finder.rb +99 -0
- data/lib/buildpack_support/rake/check_api_doc_task.rb +70 -0
- data/lib/buildpack_support/rake/dependency_cache_task.rb +87 -0
- data/lib/buildpack_support/rake/disable_remote_downloads_task.rb +80 -0
- data/lib/buildpack_support/rake/package_task.rb +133 -0
- data/lib/buildpack_support/rake/package_zip_task.rb +80 -0
- data/lib/buildpack_support/rake/repository_configuration_finder.rb +66 -0
- data/lib/buildpack_support/rake/write_version_file_task.rb +82 -0
- data/lib/buildpack_support/repository.rb +24 -0
- data/lib/buildpack_support/repository/configured_item.rb +81 -0
- data/lib/buildpack_support/repository/repository_index.rb +98 -0
- data/lib/buildpack_support/repository/wildcard_version_resolver.rb +75 -0
- data/lib/buildpack_support/shell.rb +41 -0
- data/lib/buildpack_support/snake_case.rb +30 -0
- data/lib/buildpack_support/space_case.rb +29 -0
- data/lib/buildpack_support/test/application_helper.rb +41 -0
- data/lib/buildpack_support/test/base_component_helper.rb +59 -0
- data/lib/buildpack_support/test/base_droplet_helper.rb +36 -0
- data/lib/buildpack_support/test/console_helper.rb +57 -0
- data/lib/buildpack_support/test/environment_helper.rb +32 -0
- data/lib/buildpack_support/test/internet_availability_helper.rb +29 -0
- data/lib/buildpack_support/test/logging_helper.rb +50 -0
- data/lib/buildpack_support/test/scratch_helper.rb +32 -0
- data/lib/buildpack_support/test/versioned_dependency_component_helper.rb +32 -0
- data/lib/buildpack_support/test/with_load_path_helper.rb +27 -0
- data/lib/buildpack_support/to_b.rb +38 -0
- data/lib/buildpack_support/tokenized_version.rb +157 -0
- data/lib/buildpack_support/version.rb +23 -0
- data/spec/buildpack_support/base_buildpack_spec.rb +112 -0
- data/spec/buildpack_support/buildpack_version_spec.rb +122 -0
- data/spec/buildpack_support/cache/application_cache_spec.rb +56 -0
- data/spec/buildpack_support/cache/cached_file_spec.rb +94 -0
- data/spec/buildpack_support/cache/download_cache_spec.rb +293 -0
- data/spec/buildpack_support/cache/internet_availability_spec.rb +57 -0
- data/spec/buildpack_support/cache/yield_file_with_content.rb +30 -0
- data/spec/buildpack_support/component/application_spec.rb +81 -0
- data/spec/buildpack_support/component/base_component_spec.rb +81 -0
- data/spec/buildpack_support/component/base_droplet_spec.rb +72 -0
- data/spec/buildpack_support/component/downloads_spec.rb +63 -0
- data/spec/buildpack_support/component/services_spec.rb +80 -0
- data/spec/buildpack_support/component/versioned_dependency_component_spec.rb +58 -0
- data/spec/buildpack_support/component/versioned_downloads_spec.rb +58 -0
- data/spec/buildpack_support/component/with_timing_spec.rb +30 -0
- data/spec/buildpack_support/configuration_utils_spec.rb +39 -0
- data/spec/buildpack_support/constantize_spec.rb +34 -0
- data/spec/buildpack_support/dash_case_spec.rb +41 -0
- data/spec/buildpack_support/directory_finder_spec.rb +41 -0
- data/spec/buildpack_support/filtering_pathname_spec.rb +443 -0
- data/spec/buildpack_support/format_duration_spec.rb +60 -0
- data/spec/buildpack_support/logging/delegating_logger_spec.rb +62 -0
- data/spec/buildpack_support/logging/logger_factory_spec.rb +262 -0
- data/spec/buildpack_support/qualify_path_spec.rb +42 -0
- data/spec/buildpack_support/rake/buildpack_stage_task_spec.rb +88 -0
- data/spec/buildpack_support/rake/cached_artifact_finder_spec.rb +73 -0
- data/spec/buildpack_support/rake/check_api_doc_task_spec.rb +69 -0
- data/spec/buildpack_support/rake/dependency_cache_task_spec.rb +133 -0
- data/spec/buildpack_support/rake/disable_remote_downloads_task_spec.rb +91 -0
- data/spec/buildpack_support/rake/package_task_spec.rb +335 -0
- data/spec/buildpack_support/rake/package_zip_task_spec.rb +91 -0
- data/spec/buildpack_support/rake/repository_configuration_finder_spec.rb +61 -0
- data/spec/buildpack_support/rake/write_version_file_task_spec.rb +96 -0
- data/spec/buildpack_support/repository/configured_item_spec.rb +78 -0
- data/spec/buildpack_support/repository/repository_index_spec.rb +118 -0
- data/spec/buildpack_support/repository/wildcard_version_resolver_spec.rb +73 -0
- data/spec/buildpack_support/shell_spec.rb +32 -0
- data/spec/buildpack_support/snake_case_spec.rb +45 -0
- data/spec/buildpack_support/space_case_spec.rb +41 -0
- data/spec/buildpack_support/to_b_spec.rb +41 -0
- data/spec/buildpack_support/tokenized_version_spec.rb +132 -0
- data/spec/fixtures/application/test-file +0 -0
- data/spec/fixtures/config/found-config.yml +2 -0
- data/spec/fixtures/droplet-resources/droplet-resource +0 -0
- data/spec/fixtures/stub-download-with-top-level.zip +0 -0
- data/spec/fixtures/stub-download.tar.gz +0 -0
- data/spec/fixtures/stub-download.zip +0 -0
- data/spec/fixtures/test-cache.yml +18 -0
- data/spec/fixtures/test-index.yml +2 -0
- data/spec/fixtures/test_component.rb +0 -0
- data/spec/fixtures/zip-contents/test-directory/test-deep-file +0 -0
- data/spec/fixtures/zip-contents/test-file +0 -0
- data/spec/spec_helper.rb +30 -0
- metadata +416 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
# A mixin that adds the ability to turn a +String+ into snake case
|
17
|
+
class String
|
18
|
+
|
19
|
+
# Converts a string to snake case. For example, the String +Rattle::SnakeCase+ would become +rattle/snake_case+.
|
20
|
+
#
|
21
|
+
# @return [String] The snake case rendering of this +String+
|
22
|
+
def snake_case
|
23
|
+
gsub(/::/, '/')
|
24
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
25
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
26
|
+
.tr('-', '_')
|
27
|
+
.downcase
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
# A mixin that adds the ability to turn a +String+ into space case
|
17
|
+
class String
|
18
|
+
|
19
|
+
# Converts a string to space case. For example, the String +SpaceCase+ would become +Space Case+.
|
20
|
+
#
|
21
|
+
# @return [String] The space case rendering of this +String+
|
22
|
+
def space_case
|
23
|
+
split('::').last
|
24
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2')
|
25
|
+
.gsub(/([a-z\d])([A-Z])/, '\1 \2')
|
26
|
+
.tr('-', ' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/test/environment_helper'
|
18
|
+
require 'buildpack_support/test/scratch_helper'
|
19
|
+
|
20
|
+
shared_context 'application_helper' do
|
21
|
+
include_context 'environment_helper'
|
22
|
+
include_context 'scratch_helper'
|
23
|
+
|
24
|
+
let(:application) { BuildpackSupport::Component::Application.new scratch_dir }
|
25
|
+
|
26
|
+
let(:vcap_application) { { 'application_name' => 'test-application-name' } }
|
27
|
+
|
28
|
+
let(:vcap_services) do
|
29
|
+
{ 'test-service-n/a' => [{ 'name' => 'test-service-name', 'label' => 'test-service-n/a',
|
30
|
+
'tags' => ['test-service-tag'], 'plan' => 'test-plan',
|
31
|
+
'credentials' => { 'uri' => 'test-uri' } }] }
|
32
|
+
end
|
33
|
+
|
34
|
+
before do |example|
|
35
|
+
app_fixture = example.metadata[:app_fixture]
|
36
|
+
FileUtils.cp_r "spec/fixtures/#{app_fixture.chomp}/.", scratch_dir if app_fixture
|
37
|
+
|
38
|
+
application
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/cache/application_cache'
|
18
|
+
require 'buildpack_support/repository/configured_item'
|
19
|
+
require 'buildpack_support/space_case'
|
20
|
+
require 'buildpack_support/test/application_helper'
|
21
|
+
require 'buildpack_support/test/base_droplet_helper'
|
22
|
+
require 'buildpack_support/test/console_helper'
|
23
|
+
require 'buildpack_support/test/internet_availability_helper'
|
24
|
+
require 'buildpack_support/test/logging_helper'
|
25
|
+
require 'buildpack_support/tokenized_version'
|
26
|
+
require 'pathname'
|
27
|
+
|
28
|
+
shared_context 'base_component_helper' do
|
29
|
+
include_context 'application_helper'
|
30
|
+
include_context 'base_droplet_helper'
|
31
|
+
include_context 'console_helper'
|
32
|
+
include_context 'internet_availability_helper'
|
33
|
+
include_context 'logging_helper'
|
34
|
+
|
35
|
+
let(:application_cache) { double('ApplicationCache') }
|
36
|
+
|
37
|
+
let(:component) { described_class.new context }
|
38
|
+
let(:configuration) { {} }
|
39
|
+
|
40
|
+
let(:context) do
|
41
|
+
{ application: application,
|
42
|
+
component_name: described_class.to_s.split('::').last.space_case,
|
43
|
+
configuration: configuration,
|
44
|
+
droplet: droplet }
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:uri) { 'test-uri' }
|
48
|
+
let(:version) { '0.0.0' }
|
49
|
+
|
50
|
+
# Mock application cache with cache fixture
|
51
|
+
before do |example|
|
52
|
+
allow(BuildpackSupport::Cache::ApplicationCache).to receive(:new).and_return(application_cache)
|
53
|
+
|
54
|
+
cache_fixture = example.metadata[:cache_fixture]
|
55
|
+
allow(application_cache).to receive(:get).with(uri)
|
56
|
+
.and_yield(Pathname.new("spec/fixtures/#{cache_fixture}").open, false) if cache_fixture
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/component/base_droplet'
|
18
|
+
require 'buildpack_support/snake_case'
|
19
|
+
require 'buildpack_support/test/console_helper'
|
20
|
+
require 'buildpack_support/test/logging_helper'
|
21
|
+
require 'buildpack_support/test/scratch_helper'
|
22
|
+
|
23
|
+
shared_context 'base_droplet_helper' do
|
24
|
+
include_context 'console_helper'
|
25
|
+
include_context 'logging_helper'
|
26
|
+
include_context 'scratch_helper'
|
27
|
+
|
28
|
+
let(:component_id) { described_class.to_s.split('::').last.snake_case }
|
29
|
+
|
30
|
+
let(:droplet) do
|
31
|
+
BuildpackSupport::Component::BaseDroplet.new(component_id, scratch_dir)
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:sandbox) { droplet.sandbox }
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'tee'
|
18
|
+
|
19
|
+
shared_context 'console_helper' do
|
20
|
+
|
21
|
+
STDOUT.sync
|
22
|
+
STDERR.sync
|
23
|
+
|
24
|
+
let(:stdout) { StringIO.new }
|
25
|
+
let(:stderr) { StringIO.new }
|
26
|
+
|
27
|
+
before do |example|
|
28
|
+
$stdout = Tee.open(stdout, stdout: nil)
|
29
|
+
$stderr = Tee.open(stderr, stdout: nil)
|
30
|
+
|
31
|
+
if example.metadata[:show_output]
|
32
|
+
$stdout.add STDOUT
|
33
|
+
$stderr.add STDERR
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
$stderr = STDERR
|
39
|
+
$stdout = STDOUT
|
40
|
+
end
|
41
|
+
|
42
|
+
def capture_output(out, err)
|
43
|
+
t_out = Thread.new { copy_stream(out, $stdout) }
|
44
|
+
t_err = Thread.new { copy_stream(err, $stderr) }
|
45
|
+
|
46
|
+
t_out.join
|
47
|
+
t_err.join
|
48
|
+
end
|
49
|
+
|
50
|
+
def copy_stream(source, destination)
|
51
|
+
while (buff = source.read(1))
|
52
|
+
destination.write(buff)
|
53
|
+
destination.flush
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
|
18
|
+
shared_context 'environment_helper' do
|
19
|
+
|
20
|
+
previous_environment = ENV.to_hash
|
21
|
+
|
22
|
+
let(:environment) { {} }
|
23
|
+
|
24
|
+
before do
|
25
|
+
ENV.update environment
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
ENV.replace previous_environment
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/cache/internet_availability'
|
18
|
+
require 'buildpack_support/test/logging_helper'
|
19
|
+
|
20
|
+
shared_context 'internet_availability_helper' do
|
21
|
+
include_context 'logging_helper'
|
22
|
+
|
23
|
+
# Re-initialize internet availability
|
24
|
+
before do |example|
|
25
|
+
BuildpackSupport::Cache::InternetAvailability.instance.send :initialize
|
26
|
+
BuildpackSupport::Cache::InternetAvailability.instance.available false if example.metadata[:disable_internet]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/test/console_helper'
|
18
|
+
require 'buildpack_support/test/scratch_helper'
|
19
|
+
require 'fileutils'
|
20
|
+
require 'buildpack_support/logging/logger_factory'
|
21
|
+
|
22
|
+
shared_context 'logging_helper' do
|
23
|
+
include_context 'console_helper'
|
24
|
+
include_context 'scratch_helper'
|
25
|
+
|
26
|
+
previous_log_level = ENV['JBP_LOG_LEVEL']
|
27
|
+
previous_debug_level = $DEBUG
|
28
|
+
previous_verbose_level = $VERBOSE
|
29
|
+
|
30
|
+
let(:log_contents) { (scratch_dir + '.buildpack.log').read }
|
31
|
+
|
32
|
+
before do |example|
|
33
|
+
log_level = example.metadata[:log_level]
|
34
|
+
ENV['BP_LOG_LEVEL'] = log_level if log_level
|
35
|
+
|
36
|
+
$DEBUG = example.metadata[:debug]
|
37
|
+
$VERBOSE = example.metadata[:verbose]
|
38
|
+
|
39
|
+
BuildpackSupport::Logging::LoggerFactory.instance.setup scratch_dir
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
BuildpackSupport::Logging::LoggerFactory.instance.reset
|
44
|
+
|
45
|
+
ENV['BP_LOG_LEVEL'] = previous_log_level
|
46
|
+
$VERBOSE = previous_verbose_level
|
47
|
+
$DEBUG = previous_debug_level
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'fileutils'
|
18
|
+
require 'pathname'
|
19
|
+
|
20
|
+
shared_context 'scratch_helper' do
|
21
|
+
|
22
|
+
let(:scratch_dir) { Pathname.new Dir.mktmpdir }
|
23
|
+
|
24
|
+
before do
|
25
|
+
FileUtils.mkdir_p scratch_dir
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
FileUtils.rm_rf scratch_dir
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
require 'buildpack_support/repository/configured_item'
|
18
|
+
require 'buildpack_support/test/base_component_helper'
|
19
|
+
|
20
|
+
shared_context 'versioned_dependency_component_helper' do
|
21
|
+
include_context 'base_component_helper'
|
22
|
+
|
23
|
+
# Mock repository
|
24
|
+
before do
|
25
|
+
tokenized_version = BuildpackSupport::TokenizedVersion.new(version)
|
26
|
+
|
27
|
+
allow_any_instance_of(BuildpackSupport::Repository::ConfiguredItem).to receive(:find_item) do |&block|
|
28
|
+
block.call(tokenized_version) if block
|
29
|
+
end.and_return([tokenized_version, uri])
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
# Copyright 2013-2014 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require 'spec_helper'
|
17
|
+
|
18
|
+
shared_context 'with_load_path_helper' do
|
19
|
+
|
20
|
+
def with_load_path(load_path)
|
21
|
+
$LOAD_PATH.unshift load_path
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
$LOAD_PATH.shift
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|