Skip to content

Commit bc0c60d

Browse files
committed
Non-zero exit on failure in release
Previously, if a failure occurred in release, the exit code was undefined. To meet the buildpack contract, a non-zero exit code is now returned in the case of a failure in the release script. [#49421559]
1 parent ea4d710 commit bc0c60d

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

lib/java_buildpack/release.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
require 'java_buildpack/selected_jre'
1617
require 'java_buildpack/utils/properties'
1718
require 'yaml'
1819

@@ -26,6 +27,7 @@ class Release
2627
# @param [String] app_dir The application directory used during release
2728
def initialize(app_dir)
2829
@app_dir = app_dir
30+
@selected_jre = SelectedJre.new(app_dir)
2931
end
3032

3133
# The execution entry point for release. This method is responsible for generating a payload describing the execution

spec/bin/release_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
require 'spec_helper'
17+
require 'open3'
18+
19+
describe 'release script' do
20+
21+
it 'should return non-zero if failure' do
22+
Open3.popen3("bin/release spec/fixtures/invalid_vendor") do |stdin, stdout, stderr, wait_thr|
23+
expect(wait_thr.value).to_not be_success
24+
expect(stderr.read).to eq("'sun' is not a valid Java runtime vendor\n")
25+
end
26+
end
27+
28+
it 'should return zero if success' do
29+
Open3.popen3("bin/release spec/fixtures/single_system_properties") do |stdin, stdout, stderr, wait_thr|
30+
expect(wait_thr.value).to be_success
31+
end
32+
end
33+
34+
end

0 commit comments

Comments
 (0)