I have a shell script that runs some acceptance tests for an application I’m working on. The scripts runs the tests, checks if there were errors and then exits with either 0 (success) or 1 (failure).
I have a rake task that calls the shell script, and then gets the result. The problem I’m having is, how do I pass that result to the rails console so that when I echo $? it will be equal the value returned by the shell script?
My current code is as follows:
def acceptance_tests
system("./run_tests.sh");
error_code = $?.success? ? 0 : 1
result = error_code == 0 ? 'passed' : 'failed'
puts ("The acceptance tests have #{result}.")
SystemExit.new(error_code)
end
The tests pass / fail as expected when I run them, but after they are complete, I run echo $? and it’s always equal to 0.
Any ideas about what I’m doing wrong?
In the end, changing the
SystemExit.new()toexit()worked for me.