Skip to content

Commit

Permalink
Merge pull request #5 from opiethehokie/debug
Browse files Browse the repository at this point in the history
improve debugging
  • Loading branch information
caijj committed Jun 2, 2015
2 parents a7b7467 + 101c97b commit 9b66c40
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/buildpack/compile/mono_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def mono_tar_gz(out)
private

def run_common_cmd(cmd, out)
shell.exec("bash -c 'export BUILDPACK_PATH=#{buildpack_root}; source $BUILDPACK_PATH/compile-extensions/lib/common; #{cmd}'", out)
shell.exec("bash -c 'export BUILDPACK_PATH=#{buildpack_root}; source $BUILDPACK_PATH/compile-extensions/lib/common &> /dev/null; #{cmd}'", out)
end

def buildpack_root
Expand Down
4 changes: 4 additions & 0 deletions lib/buildpack/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require_relative 'compile/kvm_installer.rb'
require_relative 'compile/kpm.rb'
require_relative 'compile/release_yml_writer.rb'
require_relative "version.rb"

require 'json'
require 'pathname'
Expand All @@ -43,6 +44,8 @@ def initialize(build_dir, cache_dir, mono_binary, nowin_dir, kvm_installer, mozr
end

def compile
puts "ASP.NET 5 buildpack version: #{BuildpackVersion.new.version}\n"
puts "ASP.NET 5 buildpack starting compile\n"
out.warn(WARNING_MESSAGE) unless WARNING_MESSAGE.nil?
step("Restoring files from buildpack cache" , method(:restore_cache))
step("Extracting mono", method(:extract_mono))
Expand All @@ -54,6 +57,7 @@ def compile
step("Moving files in to place", method(:move_to_app_dir))
step("Saving to buildpack cache", method(:save_cache))
step("Writing Release YML", method(:write_release_yml))
puts "ASP.NET 5 buildpack is done creating the droplet\n"
return true
rescue StepFailedError => e
out.fail(e.message)
Expand Down
26 changes: 26 additions & 0 deletions lib/buildpack/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'fileutils'

module AspNet5Buildpack
class BuildpackVersion
def version
version_file = File.expand_path('../../../VERSION', __FILE__)
File.open(version_file, &:readline).chomp
end
end
end
4 changes: 4 additions & 0 deletions spec/buildpack/compile/compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
AspNet5Buildpack::Compiler.new(buildDir, cacheDir, mono_binary, nowinDir, kvm_installer, mozroots, kre_installer, kpm, release_yml_writer, copier, out)
end

before do
allow($stdout).to receive(:write)
end

let(:mono_binary) do
double(:mono_binary, :extract => nil)
end
Expand Down
7 changes: 0 additions & 7 deletions spec/buildpack/compile/mono_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

describe AspNet5Buildpack::MonoInstaller do

before do
allow($stdout).to receive(:write)
end

let(:dir) do
Dir.mktmpdir
end
Expand Down Expand Up @@ -66,7 +62,6 @@
begin
dependencies = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'dependencies'))
FileUtils.mkdir_p dependencies
expect(out).to receive(:print).with(/-------> Buildpack version/)
expect(out).to receive(:print).with(/file:\/\/\//)
subject.mono_tar_gz(out)
ensure
Expand All @@ -77,7 +72,6 @@

context "when not present in dependencies dir" do
it "downloads and extracts the binary" do
expect(out).to receive(:print).with(/-------> Buildpack version/)
expect(out).to receive(:print).with(/https:\/\//)
subject.mono_tar_gz(out)
end
Expand All @@ -90,7 +84,6 @@
end

it "returns an error" do
expect(out).to receive(:print).with(/-------> Buildpack version/)
expect(out).to receive(:print).with(/DEPENDENCY_MISSING_IN_MANIFEST/)
expect { subject.mono_tar_gz(out) }.to raise_error
end
Expand Down
24 changes: 24 additions & 0 deletions spec/buildpack/version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'rspec'
require_relative "../../lib/buildpack.rb"

describe AspNet5Buildpack::BuildpackVersion do
it "can read the buildpack version from the VERSION file" do
expect(subject.version).not_to be_nil
end
end

0 comments on commit 9b66c40

Please sign in to comment.