You've already forked gnatcoll-bindings
mirror of
https://github.com/AdaCore/gnatcoll-bindings.git
synced 2026-02-12 12:59:11 -08:00
Fix ada method descriptor creation in Cpython: since python3.12 the ada method descriptor type must be properly defined and handle computation of __name__ and __qualname__. Fix internal testsuite related to API changes of e3 and add a test. Fix CI using old component names Depends-On: eng/shared/anod!7814 For eng/ide/gnatstudio#486
100 lines
3.2 KiB
Python
Executable File
100 lines
3.2 KiB
Python
Executable File
#! /usr/bin/env python3
|
|
from e3.testsuite import Testsuite
|
|
from e3.testsuite.driver import TestDriver
|
|
from e3.testsuite.result import TestStatus
|
|
from e3.os.process import Run
|
|
from e3.env import Env
|
|
from e3.fs import mkdir, cp, ls
|
|
import logging
|
|
import sys
|
|
import os
|
|
|
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
class DefaultDriver(TestDriver):
|
|
@property
|
|
def project_file(self):
|
|
result = os.path.join(self.test_env["test_dir"], "test.gpr")
|
|
if not os.path.isfile(result):
|
|
result = os.path.join(self.env.root_dir, "support", "test.gpr")
|
|
return result
|
|
|
|
@property
|
|
def build_dir(self):
|
|
return self.test_env["working_dir"]
|
|
|
|
@property
|
|
def test_source_dir(self):
|
|
return self.test_env["test_dir"]
|
|
|
|
@property
|
|
def support_source_dir(self):
|
|
return os.path.join(self.env.root_dir, "support")
|
|
|
|
def build(self, prev, slot):
|
|
self.logger = logging.getLogger(f"test.{self.test_env['test_name']}")
|
|
|
|
env = {
|
|
"TEST_SOURCES": self.test_source_dir,
|
|
"SUPPORT_SOURCES": self.support_source_dir,
|
|
}
|
|
|
|
mkdir(self.build_dir)
|
|
py_files = ls(os.path.join(self.test_source_dir, "*.py"))
|
|
if py_files:
|
|
cp(py_files, self.build_dir)
|
|
r = Run(
|
|
cmds=["gprbuild", "-P", self.project_file, "--relocate-build-tree", "-p"],
|
|
cwd=self.build_dir,
|
|
timeout=300,
|
|
env=env,
|
|
ignore_environ=False,
|
|
)
|
|
r.wait()
|
|
|
|
def run(self, prev, slot):
|
|
if self.result.status == TestStatus.ERROR: # means that status was not set
|
|
test_py = os.path.join(self.build_dir, "test.py")
|
|
if os.path.isfile(test_py):
|
|
self.test_process = Run(
|
|
cmds=[sys.executable, "./test.py"], cwd=self.build_dir, timeout=60
|
|
)
|
|
else:
|
|
self.test_process = Run(
|
|
cmds=[os.path.join(self.build_dir, "obj", "test")]
|
|
+ self.test_env.get("test_args", []),
|
|
timeout=60,
|
|
cwd=self.build_dir,
|
|
)
|
|
self.test_process.wait()
|
|
|
|
def analyze(self, prev, slot):
|
|
if self.result.status == TestStatus.ERROR: # means that status was not set
|
|
if "<=== TEST PASSED ===>" not in self.test_process.out:
|
|
self.result.set_status(TestStatus.FAIL)
|
|
else:
|
|
self.result.set_status(TestStatus.PASS)
|
|
self.push_result()
|
|
|
|
def add_test(self, dag):
|
|
self.add_fragment(dag, "build")
|
|
self.add_fragment(dag, "run", after=["build"])
|
|
self.add_fragment(dag, "analyze", after=["run"])
|
|
|
|
|
|
class GNATCOLLPython3Test(Testsuite):
|
|
"""Testsuite for the bc(1) calculator."""
|
|
|
|
test_driver_map = {"default": DefaultDriver}
|
|
default_driver = "default"
|
|
tests_subdir = "tests"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
Env.add_search_path("GPR_PROJECT_PATH", os.path.join(ROOT_DIR, "support"))
|
|
assert (
|
|
"ADA_PYTHON_HOME" in os.environ
|
|
), "ADA_PYTHON_HOME should point to Python distrib used to build the binding"
|
|
sys.exit(GNATCOLLPython3Test().testsuite_main())
|