Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2365 closed defect (fixed)

gunittest test local input file failure

Reported by: huhabla Owned by: wenzeslaus
Priority: major Milestone: 7.2.0
Component: Default Version: svn-trunk
Keywords: gunittest, testsuite, data Cc:
CPU: x86-64 Platform: Linux

Description

gunittest does not recognize local input files for tests when run with grass.gunittest.main invokation.

I have added a test for r.series.interp (r61239) that requires input files in the testsuite directory. The unittest includes module failure tests and tests with input files. When i run the test from the command line, everything is fine:

GRASS 7.1.svn (LL):~/src/grass7.1/grass_trunk/raster/r.series.interp/testsuite >ls -l
-rw-rw-r-- 1 soeren soeren   40 Jul 12 11:28 infile_2.txt
-rw-rw-r-- 1 soeren soeren 4059 Jul 12 12:35 interp_test.py
-rw-rw-r-- 1 soeren soeren   41 Jul 12 11:28 outfile_1.txt
-rw-rw-r-- 1 soeren soeren   60 Jul 12 11:28 outfile_2.txt
-rw-rw-r-- 1 soeren soeren   30 Jul 12 11:28 outfile_corrupt.txt
GRASS 7.1.svn (LL):~/src/grass7.1/grass_trunk/raster/r.series.interp/testsuite > python interp_test.py
 100%
 100%
 100%

.
 100%
 100%
 100%

.
 100%
 100%
 100%
 100%
 100%
 100%

.
ERROR: Please specify output= or outfile=


ERROR: Please specify output= and samplingpos=


ERROR: output= and outfile= are mutually exclusive


ERROR: samplingpos= and outfile= are mutually exclusive


ERROR: Unable to open output file <mo_such_file>


ERROR: Missing point position for output map <prec_4> in file
       <outfile_corrupt.txt> near line 2

.
----------------------------------------------------------------------
Ran 4 tests in 1.205s

OK

The input files are not found when i invoke the same test with the grass.gunittest.main method:

GRASS 7.1.svn (LL):~/src/grass7.1/grass_trunk/raster/r.series.interp > python -m grass.gunittest.main ~/grassdata LAEA_ERTS89 LAEA_ERTS89
./interp_test failed (see testreport/./interp_test/index.html)
GRASS 7.1.svn (LL):~/src/grass7.1/grass_trunk/raster/r.series.interp > cat testreport/./interp_test/stderr.txt .FF.
======================================================================
FAIL: test_infile (__main__.InterpolationTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/soeren/src/grass7.1/grass_trunk/raster/r.series.interp/testsuite/interp_test.py", line 47, in test_infile
    outfile="outfile_1.txt",  method="linear")
  File "/home/soeren/src/grass7.1/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/python/grass/gunittest/case.py", line 519, in assertModule
    self.fail(self._formatMessage(msg, stdmsg))
AssertionError: Running <r.series.interp> module ended with non-zero return code (1)
Called: r.series_interp(input=['prec_1,prec_5'], datapos=[0.0, 1.0], outfile='outfile_1.txt', method='linear')
See the folowing errors:
ERROR: Unable to open output file <outfile_1.txt>


======================================================================
FAIL: test_inoutfiles (__main__.InterpolationTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/soeren/src/grass7.1/grass_trunk/raster/r.series.interp/testsuite/interp_test.py", line 55, in test_inoutfiles
    outfile="outfile_2.txt",  method="linear")
  File "/home/soeren/src/grass7.1/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/python/grass/gunittest/case.py", line 519, in assertModule
    self.fail(self._formatMessage(msg, stdmsg))
AssertionError: Running <r.series.interp> module ended with non-zero return code (1)
Called: r.series_interp(infile='infile_2.txt', outfile='outfile_2.txt', method='linear')
See the folowing errors:
ERROR: Unable to open input file <infile_2.txt>


----------------------------------------------------------------------
Ran 4 tests in 1.059s

FAILED (failures=2)

Change History (5)

comment:1 by wenzeslaus, 10 years ago

Keywords: data added
Owner: changed from grass-dev@… to wenzeslaus
Status: newassigned

I forgot to put somewhere to documentation that all data for tests must be in data directory in testsuite directory. See r.slope.aspect.

When test (file) starts the data directory is copied to the current working directory set for the test (file) which is within the test report (i.e. testreport/file/path/testfilename/data) directory.

Do you agree with this approach? I decided to put everything to separate directory to keep it as organized as possible.

comment:2 by wenzeslaus, 10 years ago

Small note added to documentation in r61244.

in reply to:  1 ; comment:3 by huhabla, 10 years ago

Resolution: fixed
Status: assignedclosed

Replying to wenzeslaus:

I forgot to put somewhere to documentation that all data for tests must be in data directory in testsuite directory. See r.slope.aspect.

When test (file) starts the data directory is copied to the current working directory set for the test (file) which is within the test report (i.e. testreport/file/path/testfilename/data) directory.

Maybe linking the data directory is an option? Then we do not need to copy the data. I would expect that test developer will not write in the data directory while test runs but in the current working directory.

Do you agree with this approach? I decided to put everything to separate directory to keep it as organized as possible.

I agree with your approach, makes sense to me. I have updated the r.series.interp to use the data directory.

in reply to:  3 comment:4 by wenzeslaus, 10 years ago

Replying to huhabla:

Replying to wenzeslaus:

When test (file) starts the data directory is copied to the current working directory set for the test (file) which is within the test report (i.e. testreport/file/path/testfilename/data) directory.

Maybe linking the data directory is an option? Then we do not need to copy the data. I would expect that test developer will not write in the data directory while test runs but in the current working directory.

This should be simple and can be even made optional. Testing framework or user can also make the data directory read only but it would be hard to restore the permissions afterwards. And yes, test developer should write to current directory (I was thinking about some other directory to avoid conflicts with files outputted by testing framework but it seemed unnecessary compacted; if we decide to change it in the future, it should not be hard).

comment:5 by neteler, 8 years ago

Milestone: 7.1.07.2.0

Milestone renamed

Note: See TracTickets for help on using tickets.