开发者

Hudson unable to navigate relative directories

I have a Python project building with Hudson. Most unit tests work correctly, but any tests 开发者_Go百科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:

  • src
    • tests
      • fixtures (static files here)
      • unit (unit tests here)
    • tmp

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?


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.


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.


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]))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜