I have a run.haml file where I run a test suit. Everything works just fine but I want to display the text “Starting test suite: #{params[‘run’]}” immediately after user clicks the link that leads him to this haml.
the link clicked tells haml what suit needs to be executed
%a(href="run?run=#{file}")
Right now everything is displayed after the test suit run finishes. The run.haml page is being loaded till the script finishes.
- how does the haml processing flow work?
- can I start processing the job after the page starts rendering?
- can I display some text in a browser and then let call the test suit?
It takes minutes to finish the run of the test suit.
!!!
%html
%head
%title Running
%body
= "Starting test suite: #{params['run']}"
- output = %x[cd C:\\Program Files\\TestPro\\TestPro Automation Framework410 && ant -lib lib -f "C:\\Program Files\\TestPro\\TestPro Automation Framework410\\Output Files\\builds\\#{params['run']}.xml"]
-#The result is
%br
= output.split("\n")[-2,2].join("<BR>")
= "<br/>"*2
%a(href="/")back to suits list
Well, look — my thought here is that it’s not rendering everything (for whatever reason) until that function call returns.
If that’s the case, you’ll want to process the result of that function separately from loading the test harness page — so, you’ll want to invoke the test suite either with
That choice depends on the length of time the function (generally) takes to run — so, depending on the complexity, it may be a good candidate for something like BackgrounDRb, run_later or delayed_job, or even a custom daemon.
Finally, you may find this example of using Sinatra with delayed_job helpful.