I am writing a script that reads connection information from a config
file, and based, on what it finds, connects to multiple mysql servers
and performs tasks. To test this script, I need to set up test
servers, but getting them running without causing the tests to be
rerun when they stop is a bit…tricky. I cannot say that I’m proud of
it, but here is how I did it:
I am writing a script that reads connection information from a config
file, and based, on what it finds, connects to multiple mysql servers
and performs tasks. To test this script, I need to set up test
servers, but getting them running without causing the tests to be
rerun when they stop is a bit…tricky. I cannot say that I’m proud of
it, but here is how I did it:
Is this because of autospec? If so, you can modify the files autotest
watches. Or, you could do the server stuff in a tmpdir[1] directory.
Let me know if I’m off-target - I can’t see the definition of datadir in your snippet.
No autoscript here. I don’t doubt that there are wrappers that might
handle it, I was going for a solution in a bare rspec environment.
Still not sure I understand the problem. Can you explain what you
mean by “getting them running without causing the tests to be rerun
when they stop is a bit…tricky”? Can you paste output to illustrate
this?
1 example, 1 failure
nathan-desktop ~/work/rspec_multiple ps
PID TTY TIME CMD
10637 pts/2 00:00:00 bash
11010 pts/2 00:00:00 nedit
11286 pts/2 00:00:00 spec
11287 pts/2 00:00:00 spec
11288 pts/2 00:00:00 sh
11289 pts/2 00:00:00 sh
11290 pts/2 00:00:00 sh
11291 pts/2 00:00:00 sh
11300 pts/2 00:00:00 sleep
11301 pts/2 00:00:00 sleep
11303 pts/2 00:00:00 ps
nathan-desktop ~/work/rspec_multiple kill 11290
nathan-desktop ~/work/rspec_multiple nohup: redirecting stderr to
stdout
nohup: redirecting stderr to stdout
F
NameError in ‘We can do tests in the air Here is the first test’
undefined local variable or method `not_raise’ for
#Spec::Example::ExampleGroup::Subclass_1:0xb7a4e900
./tc_forks_spec.rb:8:
./tc_forks_spec.rb:2:
Finished in 0.006251 seconds
1 example, 1 failure
nathan-desktop ~/work/rspec_multiple ps
PID TTY TIME CMD
10637 pts/2 00:00:00 bash
11010 pts/2 00:00:01 nedit
11286 pts/2 00:00:00 spec
11288 pts/2 00:00:00 sh
11291 pts/2 00:00:00 sh
11346 pts/2 00:00:00 spec
11347 pts/2 00:00:00 spec
11348 pts/2 00:00:00 sh
11349 pts/2 00:00:00 sh
11350 pts/2 00:00:00 sh
11351 pts/2 00:00:00 sh
11436 pts/2 00:00:00 sleep
11437 pts/2 00:00:00 sleep
11438 pts/2 00:00:00 sleep
11439 pts/2 00:00:00 ps
There are variations here. This particular example spawned two new
spec processes when I killed one of the sh process. I thought it
worthwhile to publish the one that works.