File: basic.py

package info (click to toggle)
libgnatcoll 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,920 kB
  • sloc: ada: 47,749; python: 1,117; ansic: 379; makefile: 229; sh: 25
file content (62 lines) | stat: -rw-r--r-- 2,137 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os

from e3.fs import cp
from e3.os.fs import df
from e3.testsuite.driver.classic import ClassicTestDriver
from e3.testsuite.control import YAMLTestControlCreator

from drivers import gprbuild, run_test_program


class BasicTestDriver(ClassicTestDriver):
    """Default GNATcoll testsuite driver.

    In order to declare a test:

    1- Create a directory with a test.yaml inside
    2- Add test sources in that directory
    3- Add a main called test.adb that use support/test_assert.ads package.
    4- Do not put test.gpr there, it breaks the test, if you need a project
       file for testing, name it something else.
    5- If you need additional files for you test, list them in test.yaml:
       data:
           - "your_file1"
           - "your_file2"
    """

    # We want to copy only specific files (files referenced by the "data" key
    # in test.yaml).
    copy_test_directory = False

    @property
    def test_control_creator(self):
        return YAMLTestControlCreator({
            'env': self.env,
            'test_env': self.test_env,
            'disk_space': lambda: df(self.env.working_dir)
        })

    def run(self):
        # Build the test program
        if self.test_env.get('no-coverage'):
            gpr_project_path = self.env.gnatcoll_debug_gpr_dir
        else:
            gpr_project_path = self.env.gnatcoll_gpr_dir
        gprbuild(self, gcov=self.env.gcov, gpr_project_path=gpr_project_path)

        # Copy the requested data files
        for data in self.test_env.get('data', []):
            cp(os.path.join(self.test_env['test_dir'], data),
               self.test_env['working_dir'], recursive=True)

        # Run the test program
        test_exe = self.test_env.get('test_exe', 'obj/test')
        process = run_test_program(
            self,
            [os.path.join(self.test_env['working_dir'], test_exe)],
            timeout=self.default_process_timeout)
        self.output += process.out.decode('utf-8')

    def compute_failures(self):
        return (['Success marker not found']
                if '<=== TEST PASSED ===>' not in self.result.log.log else [])