Sha256: 0955612a58957ee221d0403ef82db8f21a08c0c69753a2dc4fe77c39dd9ac5df
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
# https://raw.githubusercontent.com/metric_fu/metric_fu/master/spec/capture_warnings.rb require "rubygems" if RUBY_VERSION =~ /^1\.8/ require "bundler/setup" require "rspec/core" require "rspec/expectations" require "tempfile" require "fileutils" stderr_file = Tempfile.new("app.stderr") app_root ||= Dir.pwd output_dir = File.join(app_root, "tmp") FileUtils.mkdir_p(output_dir) bundle_dir = File.join(app_root, "bundle") RSpec.configure do |config| config.before(:suite) do $stderr.reopen(stderr_file.path) $VERBOSE = true end config.after(:suite) do stderr_file.rewind lines = stderr_file.read.split("\n").uniq stderr_file.close! $stderr.reopen(STDERR) app_warnings, other_warnings = lines.partition { |line| line.include?(app_root) && !line.include?(bundle_dir) } if app_warnings.any? puts <<-WARNINGS #{'-' * 30} app warnings: #{'-' * 30} #{app_warnings.join("\n")} #{'-' * 75} WARNINGS end if other_warnings.any? output_file = File.join(output_dir, "warnings.txt") File.write(output_file, other_warnings.join("\n") << "\n") puts puts "Non-app warnings written to tmp/warnings.txt" puts end # fail the build... if app_warnings.any? abort "Failing build due to app warnings: #{app_warnings.inspect}" end end end
Version data entries
8 entries across 8 versions & 3 rubygems