Update `README-TESTS.md` with test file policy

main
postscript-dev 3 years ago
parent 559914d41d
commit 09f566dbde
No known key found for this signature in database
GPG Key ID: 285C4DA49C8FCF6D

@ -3,6 +3,7 @@
- [README-TESTS](#README-TESTS) - [README-TESTS](#README-TESTS)
- [Running the test suite](#running-the-test-suite) - [Running the test suite](#running-the-test-suite)
- [Writing new tests](#writing-new-tests) - [Writing new tests](#writing-new-tests)
- [Test data](#test-data)
- [Test suite](#test-suite) - [Test suite](#test-suite)
- [Configuration](#configuration) - [Configuration](#configuration)
- [INI style](#ini-style) - [INI style](#ini-style)
@ -114,6 +115,20 @@ When creating new tests, follow roughly these steps:
[TOC](#TOC) [TOC](#TOC)
<div id="test-data"/>
## Test data
All test files (e.g. images, `.exv`, etc) are stored in the `$data_path`
directory, with any temporary copies in the `$tmp_path` directory (see
[Creating file copies](#creating-file-copies)).
When writing tests, try to reuse existing data files rather than add new ones.
If new files are required, prefer adding only the metadata (`.exv`) instead of
the whole image. These steps help to reduce the size of the test data
directory.
[TOC](#TOC)
<div id="test-suite"/> <div id="test-suite"/>
## Test suite ## Test suite
@ -612,24 +627,25 @@ and your test case will get only the specified environment variables.
### Creating file copies ### Creating file copies
For tests that modify their input file it is useful to run these with a For tests that modify their input file it is useful to run these with a
disposable copy of the input file and not with the original. For this purpose disposable copy of the input file and not with the original. For this purpose,
the test suite features a decorator which creates a copy of the supplied files the test suite features a decorator which creates a copy of the supplied files
and deletes the copies after the test ran. and preserves the copies after the test finishes. All temporary copies are
stored in the `$tmp_path` directory.
Example: Example:
```python ```python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import system_tests import system_tests, CopyTmpFiles
@system_tests.CopyFiles("$filename", "$some_path/another_file.txt") @CopyTmpFiles("$data_path/invalid_input_file.txt")
class AnInformativeName(metaclass=system_tests.CaseMeta): class AnInformativeName(metaclass=system_tests.CaseMeta):
filename = "invalid_input_file" filename = path("$tmp_path/invalid_input_file.txt")
commands = [ commands = [
"$binary -c $import_file -i $filename" "$binary --option $filename"
] ]
retval = ["$abort_exit_value"] retval = ["$abort_exit_value"]
stdout = ["Reading $filename"] stdout = ["Reading $filename"]
@ -640,11 +656,10 @@ error in $filename
] ]
``` ```
In this example, the test suite would automatically create a copy of the files In this example, the test suite would automatically create a copy of the file
`invalid_input_file` and `$some_path/another_file.txt` (`some_path` would be of `$data_path/invalid_input_file.txt` called `$tmp_path/invalid_input_file.txt`.
course expanded too) named `invalid_input_file_copy` and After the test runs, the temporary copy is preserved. Please note that variable
`$some_path/another_file_copy.txt`. After the test ran, the copies are expansion in the filenames is possible.
deleted. Please note that variable expansion in the filenames is possible.
[TOC](#TOC) [TOC](#TOC)

Loading…
Cancel
Save