From 82fbd34149c163b0d36c7758621b6d8bcb1ee1cb Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 25 Nov 2018 20:45:32 -0500 Subject: [PATCH] add dspec task to test dist file; revert spec task to normal behavior --- Rakefile.rb | 11 +++++++++-- spec/build_tests_spec.rb | 10 +++++++++- spec/spec_helper.rb | 6 +++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Rakefile.rb b/Rakefile.rb index 393d796..28225f3 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -18,8 +18,6 @@ task :build_dist do end RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args| - FileUtils.mkdir_p("test") - FileUtils.cp("dist/rscons", "test/rscons.rb") if args.example_string ENV["partial_specs"] = "1" task.rspec_opts = %W[-e "#{args.example_string}" -f documentation] @@ -28,6 +26,15 @@ end task :spec => :build_dist +desc "Dist Specs" +task :dspec, [:example_string] do |task, args| + FileUtils.mkdir_p("test") + FileUtils.cp("dist/rscons", "test/rscons.rb") + ENV["dist_specs"] = "1" + Rake::Task["spec"].invoke(args.example_string) + ENV.delete("dist_specs") +end + YARD::Rake::YardocTask.new do |yard| yard.files = ['lib/**/*.rb'] end diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index ed6c733..a4af799 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -96,7 +96,12 @@ describe Rscons do [] end rscons_args = options[:rscons_args] || [] - command = %W[ruby -I. -r _simplecov_setup #{@owd}/test/rscons.rb] + rsconscript_args + rscons_args + operation + if ENV["dist_specs"] + exe = "#{@owd}/test/rscons.rb" + else + exe = "#{@owd}/bin/rscons" + end + command = %W[ruby -I. -r _simplecov_setup #{exe}] + rsconscript_args + rscons_args + operation @statics[:build_test_id] ||= 0 @statics[:build_test_id] += 1 command_prefix = @@ -128,6 +133,9 @@ end ENV["TERM"] = nil #{options[:ruby_setup_code]} EOF + unless ENV["dist_specs"] + fh.puts %[$LOAD_PATH.unshift(#{@owd.inspect} + "/lib")] + end end stdout, stderr, status = nil, nil, nil Bundler.with_clean_env do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 60990ba..f939411 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,4 +12,8 @@ SimpleCov.start do merge_timeout 3600 end -require_relative "../test/rscons" +if ENV["dist_specs"] + require_relative "../test/rscons" +else + require "rscons" +end