Kyuafile and current working directory of tests?

19 views
Skip to first unread message

Craig Rodrigues

unread,
Sep 5, 2014, 5:32:56 PM9/5/14
to kyua-d...@googlegroups.com
Hi,

I have an existing set of unit tests that are structured like this:

/tests/test_funcs.sh
/tests/test1/test.sh
/tests/test2/test.sh
/tests/test3/test.sh

Inside each test.sh, the first line of the test is

. ../test_funcs.sh

I have put Kyuafiles:

/tests/Kyuafile
/tests/test1/test.sh
/tests/test2/test.sh
/tests/test3/test.sh


If I do:

cd /tests
kyua test

The tests fail because they cannot source ../test_funcs.sh

That is because kyua changes the working directory to a temporary directory
for test case isolation.

Does anyone have any advice for how I can work around this problem?

Thanks.
--
Craig

Julio Merino

unread,
Sep 5, 2014, 6:56:53 PM9/5/14
to kyua-d...@googlegroups.com
On Fri, Sep 5, 2014 at 5:32 PM, Craig Rodrigues <rod...@freebsd.org> wrote:
The tests fail because they cannot source ../test_funcs.sh

That is because kyua changes the working directory to a temporary directory
for test case isolation.

Does anyone have any advice for how I can work around this problem?

If they are atf test programs: $(atf_get_srcdir)/../test_funcs.sh

If not: $(dirname $0)/../test_funcs.sh

--
Julio Merino | BCD / PD SRE | jm...@google.com | +1 (347) 694-0576

Craig Rodrigues

unread,
Sep 5, 2014, 8:36:27 PM9/5/14
to kyua-d...@googlegroups.com
On Fri, Sep 5, 2014 at 3:56 PM, 'Julio Merino' via kyua-discuss
<kyua-d...@googlegroups.com> wrote:
> On Fri, Sep 5, 2014 at 5:32 PM, Craig Rodrigues <rod...@freebsd.org> wrote:
>>
>> The tests fail because they cannot source ../test_funcs.sh
>>
>> That is because kyua changes the working directory to a temporary
>> directory
>> for test case isolation.
>>
>> Does anyone have any advice for how I can work around this problem?
>
>
> If they are atf test programs: $(atf_get_srcdir)/../test_funcs.sh
>
> If not: $(dirname $0)/../test_funcs.sh



These tests are not ATF, just plain Bourne shell scripts.
Using: "$(dirname $0)/../test_funcs.sh" worked.

Thanks!
--
Craig
Reply all
Reply to author
Forward
0 new messages