[Bash-completion-devel] Bump match_max for test suite?
Guillaume Rousse
Guillaume.Rousse at inria.fr
Sun Jan 31 21:38:25 UTC 2010
Le 20/01/2010 22:27, Freddy Vulto a écrit :
> On 100116 13:51, Guillaume Rousse wrote:
>> Avoiding assumptions whenever possible ensure consistent results, that's
>> my point. The test you describe will fail, without added value to
>> anyone, when run by a user with a 'locanything' host in its
>> /etc/resolv.conf file.
>
> Why would that fail? The completion would produce:
>
> $ loc<TAB>
> ... localhost ... locanything ...
>
> and if the test checks for 'localhost' "among possibly others" thus:
> "\s+localhost\s+" we have tested successfully that at least `localhost' is
> listed as a possible completion.
Right, but this requires the checks to be quite relax among their
expected result. I can't find cases where it hurts, tough, apart
performance and limits issues.
> I think both tests on top of the user's environment and tests within a constant
> test environment serve a purpose. But I also found tests on top of the user's
> environment easier to write (and definitely useful).
>
> The way I go about writing tests is that I first try to make the utility point
> to its test/fixtures/<util> directory, and if this isn't possible, I try to let
> the testcase add values from the current user's environment to the expected
> results at run-time.
>
> The only time when I long for a fixed test environment, is when the steps above
> fail or are becoming difficult. I've been looking at `chroot' to create some
> kind of `chroot jail' in which tests could be run but I don't have any
> experience with chroot and didn't really feel the need so left it at that...
> I'm also afraid that maintaining a large test environment is putting a burden
> on development, so at least we'd better create tiny test environments per
> utility within the test/fixtures directory?
Absolutly, that was my point.
> I saw you already did a:
>
> assert_bash_exec {HOME=$TESTDIR}
>
> within test/lib/completions/xhost.exp, which is in fact creating a constant
> test environment. Maybe it's better to point it to $TESTDIR/fixtures/xhost?.
> And restore HOME within the teardown()? I've tried relocating HOME for ssh,
> but this doesn't work for ssh (it keeps looking at the old HOME dir or in fact
> retrieves HOME from somewhere else I believe).
>
> What are your ideas on creating a constant test environment? Would chroot be
> useful?
It seems a bit oversized, and requires root privileges morevoer. I was
more thinking about abusing environment variables whenever possible,
such as HOSTFILE each time hostname completion is used, for example. And
sharing those tricks in generic fixtures, as you suggest.
--
BOFH excuse #94:
Internet outage
More information about the Bash-completion-devel
mailing list