[Avocado-devel] [RFC] white-spaces in test references

Amador Pahim apahim at redhat.com
Thu Nov 10 13:31:06 UTC 2016


Hi folks,

Please consider this series of tests. Comments are after them.

-------------------------------------------------------------------------------
INSTRUMENTED:
$ cp examples/tests/passtest.py examples/tests/pass\ test.py

Example 1:

$ avocado run 'pass test.py'
PASS

Example 2:

$ avocado run 'examples/tests/pass test.py'
PASS

Example 3:

$ avocado run pass\ test.py
PASS

Example 4:

$ avocado run examples/tests/pass\ test.py
PASS

Example 5:

$ avocado run 'pass\ test.py'
Unable to resolve reference(s) 'pass\ test.py' with plugins(s) 'file',
'external', try running 'avocado list -V pass\ test.py' to see the
details.

Example 6:

$ avocado run 'examples/tests/pass\ test.py'
PASS

-------------------------------------------------------------------------------

SIMPLE TESTS
$ cd /tmp/

Example 7:

$ avocado run 'test script.sh'
PASS

Example 8:

$ avocado run '/tmp/test script.sh'
ERROR
 Running '/tmp/'/tmp/test script.sh''
 ...
 File "/home/apahim/src/avocado/avocado/utils/process.py", line 383,
in _init_subprocess
      raise exc
 OSError: File '/tmp/'/tmp/test' not found

Example 9:

$ avocado run test\ script.sh
PASS

Example 10:

$ avocado run /tmp/test\ script.sh
ERROR
 Running '/tmp/'/tmp/test script.sh''
 ...
 File "/home/apahim/src/avocado/avocado/utils/process.py", line 383,
in _init_subprocess
      raise exc
 OSError: File '/tmp/'/tmp/test' not found

Example 11:

$ avocado run 'test\ script.sh'
PASS

Example 12:

$ avocado run '/tmp/test\ script.sh'
PASS


SIMPLE TESTS WITH ARGUMENTS:

Example 13:

$ avocado run 'test script.sh arg1'
Unable to resolve reference(s) 'test script.sh arg1' with plugins(s)
'file', 'external', try running 'avocado list -V test script.sh arg1'
to see the details.

Example 14:

$ avocado run '/tmp/test script.sh arg1'
Unable to resolve reference(s) '/tmp/test script.sh arg1' with
plugins(s) 'file', 'external', try running 'avocado list -V /tmp/test
script.sh arg1' to see the details.

Example 15:

$ avocado run 'test\ script.sh arg1'
PASS, script receives arg1.

Example 16:

$ avocado run '/tmp/test\ script.sh arg1'
PASS, script receives arg1.

-------------------------------------------------------------------------------

Example 8 and Example 10 are affected by an issue in
SimpleTest.filename. This issue is caused by the pipes.quote(filename)
call in the FileLoader. The pipes.quote(filename) is putting single
quotes around the entire filename and making
os.path.abspath(filename), which is present in SimpleTest.filename, to
return the incorrect location. Btw, the same issue is affecting
filenames with non-ascii characters.

In order to fix this issue, we have some options, like 'handle the
quoted filename coming from the loader inside the
SimpleTest.filename', which fixes Examples 8 and 10 and does not
change anything else, or 'to remove the pipes.quote(filename) from the
loader' which makes the syntax on Examples 7, 8, 9 and 10 invalid (so
all white-spaces in filenames have to be escaped AND the test
reference have to be enclosed inside quotes when the filename contains
white-spaces, like in examples 11, 12, 15 and 16).

But this issue raised a new discussion: right now, for both
INSTRUMENTED and SIMPLE tests, we accept non-escaped white-spaces in
the test reference, as long as the test reference is enclosed into
quotes (Examples 1, 2, 7 and 8). But there is one exception: if we
have a SIMPLE test with white-spaces in the filename AND arguments,
then the white-spaces in the filename have to be escaped (Examples 15
and 16). This change of behaviour based on the presence/absence of
arguments seems confusing from the user perspective. This syntax
(Examples 1, 2, 7 and 8) maybe can make sense for INSTRUMENTED tests,
since we don't have arguments there, but it does not make sense for
SIMPLE tests, because we do support arguments in the test references
for SIMPLE tests.

So, before sending a new Pull Request, I'd like to have some feedback
about this. What are the valid syntaxes that we have to support and
what syntaxes should not be valid from the list of examples above?
Should we keep all of them as they are currently and just fix Examples
8 and 10? Or the Examples 7, 8, 9 and 10 are looking wrong for you as
well?

Best,
--
apahim




More information about the Avocado-devel mailing list