Add dspec task to test distributable script

This commit is contained in:
Josh Holtrop 2023-09-24 18:54:19 -04:00
parent 547dbd3850
commit db6dc0e099
3 changed files with 19 additions and 1 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@
/tmp/
/.rspec_status
/spec/run/
/dspec/

View File

@ -10,6 +10,18 @@ RSpec::Core::RakeTask.new(:spec, :example_pattern) do |task, args|
end
end
# dspec task is useful to test the distributable release script, but is not
# useful for coverage information.
desc "Dist Specs"
task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.rm_rf("dspec")
FileUtils.mkdir_p("dspec")
FileUtils.cp("dist/propane", "dspec/propane")
ENV["dist_specs"] = "1"
Rake::Task["spec"].execute(args)
ENV.delete("dist_specs")
end
task :default => :spec
desc "Build user guide"

View File

@ -11,7 +11,12 @@ describe Propane do
def build_parser(options = {})
options[:name] ||= ""
command = %W[./propane.sh spec/run/testparser#{options[:name]}.propane spec/run/testparser#{options[:name]}.#{options[:language]} --log spec/run/testparser#{options[:name]}.log]
if ENV["dist_specs"]
propane = "dspec/propane"
else
propane = "./propane.sh"
end
command = %W[#{propane} spec/run/testparser#{options[:name]}.propane spec/run/testparser#{options[:name]}.#{options[:language]} --log spec/run/testparser#{options[:name]}.log]
if (options[:capture])
stdout, stderr, status = Open3.capture3(*command)
Results.new(stdout, stderr, status)