Here is the "problem of the moment":
I'm writing tests for some web modules and I've broken the test down into separate files for testing separate things. Now, this is the backend code for a web app and the whole process is started by logging in. This sets up a session with a SID that is passed back to the user and is used in the future to re-establish the session. Pretty standard stuff.
So, what I want to do is create the session in one test file and run some tests... but, I want to store the SID into the %ENV for the next test to use and re-establish the session.
The kicker seems to be that I'm using Test::Harness to drive the testing and it seems to fork off each test, so changes to %ENV aren't propagated to the next script.
I've also tried setting (and exporting) the environment via the system command using every variant I can think of and I keep getting something along the lines of "export file not found".
Now, I know that export is specific to the bash shell so my first thought was that the test aren't even running in a bash shell, even tho I am. Is this true?
So, I changed my system command to:
system ("/bin/bash export GB_TEST_SID=$sid");
export GB_TEST_SID=: No such file or directory
#show the current env phillip@prometheus:~$ echo $MY_TEST
# launch a child shell phillip@prometheus:~$ bash phillip@prometheus:~$ ps PID TTY TIME CMD 28108 pts/12 00:00:00 bash 28119 pts/12 00:00:00 bash 28124 pts/12 00:00:00 ps
# export and confirm phillip@prometheus:~$ export MY_TEST="hello world" phillip@prometheus:~$ echo $MY_TEST hello world
# launch a child from the child phillip@prometheus:~$ bash phillip@prometheus:~$ ps PID TTY TIME CMD 28108 pts/12 00:00:00 bash 28119 pts/12 00:00:00 bash 28125 pts/12 00:00:00 bash 28130 pts/12 00:00:00 ps
# check the environmnet... it works phillip@prometheus:~$ echo $MY_TEST hello world
# exit the child of the child phillip@prometheus:~$ exit exit
# reconfirm env still set phillip@prometheus:~$ echo $MY_TEST hello world
# exit the child... now back in the parent phillip@prometheus:~$ exit exit
# and test the env phillip@prometheus:~$ echo $MY_TEST
phillip@prometheus:~$
Re:Use Module::Build-notes
phillup on 2004-07-22T21:56:16
That does look handy... thanks!
I just really wish I'd started with this (and the tests!!) two years ago when I started writing the modules!!
The customer wants some pretty significant changes and I've convinced them that we need some tests to insure that the functionality doesn't degrade with all of the changes... so... I'm basically backporting tests into the system while trying to provide new features.
And, the new features are needed soon (of course).
Yuck.
(OK... enough complaining. Back to work.)
Again, thanks!