Matt Norris
Matt Norris

Reputation: 8836

Hudson unable to navigate relative directories

I have a Python project building with Hudson. Most unit tests work correctly, but any tests that require writing to the file system (I have a class that uses tarfiles, for example) can't find the tmp directory I have set up for intermediate processing (my tearDown methods remove any files under the relative tmp directory).

Here is my project structure:

Here is an example error:

OSError: [Errno 2] No such file or directory: '../../tmp'

I assume this is happening because Hudson is not processing the files while in the directory unit, but rather some other working directory.

What is Hudson's working directory? Can it be configured? Can relative paths work at all?

Upvotes: 1

Views: 642

Answers (3)

Vinay Sajip
Vinay Sajip

Reputation: 99485

I don't know how you're initializing your workspace, but typically it's done by checking your project out of version control into the workspace. If this is true in your case, the easiest thing to do is to add your tmp directory to version control (say, with a README file in it, if your version control system doesn't support directories). Then, the tmp directory will get checked out into your workspace and things should work again.

Upvotes: 1

rjohnston
rjohnston

Reputation: 7373

Each job in Hudson has it's own working directory, at /path/to/hudson/jobs/[job name]/workspace/

For individual jobs, you can set the "Use custom workspace" option (under "Advanced Project Options") to define where the workspace will be.

I guess it would depend on how your tests are being run, but if you inspect the job's workspace you should be able to find where Hudson is writing the files to.

Upvotes: 2

kepkin
kepkin

Reputation: 1145

I don't know anyhting about Hudson, but this is what I do to ensure, that relative path are working right:

os.chdir(os.path.dirname(sys.argv[0]))

Upvotes: 0

Related Questions