Class: ASAutotest::CompilerShell
- Inherits:
-
Object
- Object
- ASAutotest::CompilerShell
show all
- Includes:
- Logging
- Defined in:
- lib/asautotest/compiler-shell.rb
Defined Under Namespace
Classes: PromptNotFound
Constant Summary
collapse
- PROMPT =
"\n(fcsh) "
Constants included
from Logging
Logging::PREFIX
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
#barf, #end_saying, #end_whisper, #hint, #new_logging_section, #say, #say_with_block, #say_without_block, #shout, #start_saying, #start_whisper, verbose=, verbose?, #verbose?, #whisper, #whisper_with_block, #whisper_without_block
Constructor Details
Returns a new instance of CompilerShell.
30
31
32
|
# File 'lib/asautotest/compiler-shell.rb', line 30
def initialize(options)
@compilation_requests = options[:compilation_requests]
end
|
Instance Attribute Details
#compilation_requests ⇒ Object
Returns the value of attribute compilation_requests.
28
29
30
|
# File 'lib/asautotest/compiler-shell.rb', line 28
def compilation_requests
@compilation_requests
end
|
Instance Method Details
#compilation_commands ⇒ Object
57
58
59
|
# File 'lib/asautotest/compiler-shell.rb', line 57
def compilation_commands
@compilation_requests.map { |x| x.compilation_command }
end
|
#read_until_prompt ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/asautotest/compiler-shell.rb', line 68
def read_until_prompt
result = ""
until result.include? PROMPT
result << @process.readpartial(100)
end
result.lines.entries[0 .. -2]
rescue EOFError
raise PromptNotFound, result
end
|
#run_compilation(request, result) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/asautotest/compiler-shell.rb', line 61
def run_compilation(request, result)
stopwatch = Stopwatch.new
@process.puts(request.compilation_command)
OutputParser.parse(read_until_prompt, request, stopwatch, result)
stopwatch.stop
end
|
#run_compilations(result) ⇒ Object
51
52
53
54
55
|
# File 'lib/asautotest/compiler-shell.rb', line 51
def run_compilations(result)
for request in @compilation_requests
run_compilation(request, result)
end
end
|
#start ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/asautotest/compiler-shell.rb', line 34
def start
say "Starting compiler shell" do
@process = IO.popen("#{FCSH} 2>&1", "r+")
read_until_prompt
end
rescue PromptNotFound => error
shout "Could not find FCSH prompt:"
for line in error.message.lines do
barf line.chomp
end
if error.message.include? "command not found"
shout "Please make sure that fcsh is in your PATH."
shout "Alternatively, set the ‘FCSH’ environment variable."
end
exit -1
end
|