Skip to content

Commit a6cef1b

Browse files
committed
Merge branch 'cgfrost-master'
[resolves #58]
2 parents 3376215 + 56f5608 commit a6cef1b

File tree

5 files changed

+105
-3
lines changed

5 files changed

+105
-3
lines changed

bin/detect

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ end.compact
3030
if components.empty?
3131
abort
3232
else
33-
puts components.join(' ')
33+
str = components.join(' ')
34+
puts str.length > 255 ? str.slice(0..251) + '...' : str
3435
end

spec/bin/detect_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,27 @@
2323
it 'should return zero if success',
2424
app_fixture: 'integration_valid' do
2525

26-
run("bin/detect #{app_dir}") { |status| expect(status).to be_success }
26+
run("bin/detect #{app_dir}") do |status|
27+
expect(status).to be_success
28+
expect(stdout.string.rstrip.length).to be < 255
29+
end
2730
end
2831

2932
it 'should fail to detect when no containers detect' do
3033
run("bin/detect #{app_dir}") do |status|
3134
expect(status).not_to be_success
35+
expect(stdout.string).to be_empty
36+
end
37+
end
38+
39+
it 'should truncate long detect strings',
40+
app_fixture: 'integration_valid',
41+
buildpack_fixture: 'integration_long_detect_tag' do
42+
43+
run("bin/detect #{app_dir}") do |status|
44+
expect(status).to be_success
45+
expect(stdout.string.rstrip.length).to eq 255
46+
expect(stdout.string.rstrip).to end_with '...'
3247
end
3348
end
3449

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Cloud Foundry Java Buildpack
2+
# Copyright (c) 2013 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+
# Configuration for components to use in the buildpack
17+
---
18+
containers:
19+
- "JavaBuildpack::Container::LongDetectTags"
20+
21+
# In order to use Oracle JREs instead of OpenJDK, you must comment out the OpenJDK line and uncomment the Oracle line.
22+
# Please see the documentation for more detail.
23+
jres:
24+
- "JavaBuildpack::Jre::OpenJdkJRE"
25+
# - "JavaBuildpack::Jre::OracleJRE"
26+
27+
frameworks: []
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Encoding: utf-8
2+
# Cloud Foundry Java Buildpack
3+
# Copyright 2013 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
require 'java_buildpack/component/base_component'
18+
require 'java_buildpack/container'
19+
20+
module JavaBuildpack
21+
module Container
22+
23+
# Encapsulates the functionality for contributing really long detect tags.
24+
class LongDetectTags < JavaBuildpack::Component::BaseComponent
25+
26+
# (see JavaBuildpack::Component::BaseComponent#detect)
27+
def detect
28+
[[].fill(0, 300) { 'A' }.join]
29+
end
30+
31+
# (see JavaBuildpack::Component::BaseComponent#compile)
32+
def compile
33+
end
34+
35+
# (see JavaBuildpack::Component::BaseComponent#release)
36+
def release
37+
end
38+
39+
end
40+
41+
end
42+
end

spec/integration_helper.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,25 @@
2525
include_context 'console_helper'
2626
include_context 'logging_helper'
2727

28+
let(:buildpack_dir) { Pathname.new Dir.mktmpdir }
29+
30+
before do
31+
FileUtils.mkdir_p buildpack_dir
32+
end
33+
34+
before do |example|
35+
%w(bin config lib resources).each { |dir| FileUtils.cp_r dir, buildpack_dir }
36+
37+
buildpack_fixture = example.metadata[:buildpack_fixture]
38+
FileUtils.cp_r "spec/fixtures/#{buildpack_fixture.chomp}/.", buildpack_dir if buildpack_fixture
39+
end
40+
41+
after do
42+
FileUtils.rm_rf buildpack_dir
43+
end
44+
2845
def run(command)
29-
Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr|
46+
Open3.popen3(command, chdir: buildpack_dir) do |_stdin, stdout, stderr, wait_thr|
3047
capture_output stdout, stderr
3148
yield wait_thr.value if block_given?
3249
end

0 commit comments

Comments
 (0)