Skip to content

Commit

Permalink
Pushed debug option into file handling.
Browse files Browse the repository at this point in the history
Cleaned up potential for extra lines at end of output
Errors redirected to stderr
  • Loading branch information
mvandervoord committed Apr 22, 2016
1 parent 3b3ccc9 commit a8d2c15
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions bin/ceedling
Expand Up @@ -196,6 +196,8 @@ else
abort
when /--gtest/
options[:pretend_we_are_gtest] = true
when /--debug/
options[:outfile] = "debug.txt"
else
options[:args] += v + " "
end
Expand All @@ -211,8 +213,13 @@ else
ENV["PATH"] = path
end

if (options[:outfile])
f = File.open(options[:outfile],'w')
f << ARGV.inspect << "\n\n"
f << options.inspect << "\n\n"
end

#run rake and capture all the output
results = ""
okay_to_print = !(options[:pretend_we_are_gtest])
begin
options[:cmd] = if (options[:pretest].nil? || options[:pretest].empty?)
Expand All @@ -226,22 +233,17 @@ else
okay_to_print = true if ((options[:pretend_we_are_gtest]) && (line.match(/\[\=+\]/)))
line.gsub!(/(?<!\w)rake(?!\w)/,'ceedling') if (options[:args].strip == "-T")
puts(line) if okay_to_print
f.puts(line) if (okay_to_print && options[:outfile])
end
rescue Errno::EIO
end
end
rescue Exception => e
results += e.inspect #unless (e == PTY::ChildExited)
STDERR.puts inspect unless (e == PTY::ChildExited)
end

#File.open("debug.txt",'w'){|f| f << ARGV.inspect << "\n\n" << options.inspect << "\n\n" << results }

#dump the results back out stdout unless otherwise specified
if (options[:outfile].nil?)
puts results
else
File.open(options[:outfile],'w') {|f| f << results }
end
f.close if options[:outfile]
true

#===================================================================================================================
end

0 comments on commit a8d2c15

Please sign in to comment.