AdaCore / AdaCore/e3-core

Allow serializing BaseEnv instances

Open
#723 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
32
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Hi!

Some e3-testsuite-based testsuites define a test.py script for each testcase, make the driver execute that script plus some pre-/post-processing steps. These test.py scripts typically import a harness module shared with the main testsuite process, and that module will load data that has been serialized by the driver.

This data generally includes

  • some of the main process's command-line options, i.e. information about the run as a whole,
  • the test_env received by the driver, i.e. information that parameterizes test.py.

As things stand, testsuite drivers need to devise their own serialization strategy, e.g. a record where the driver will tuck Env() platforms, test_env items, etc; the driver will pickle that record, spawn test.py and let it un-pickle the record.

It would be convenient to use e3.env's existing de/serialization code for this, using a protocol along the lines of:

# Driver side:
testcase_env = BaseEnv.from_env()       # Copy Env singleton into a non-global instance.
testcase_env.test_env = self.test_env   # Add per-testcase data.
testcase_env.store(self.working_dir(harness.TESTCASE_ENV_FILE))
self.shell(["test.py"])                 # Spawn test.py in self.working_dir().

# test.py side:
Env.restore(harness.TESTCASE_ENV_FILE)

However, currently this cannot work:

  • BaseEnv.from_env only copies the build, host & target platforms; it does not copy other attributes;
  • BaseEnv.copy does not accept Env parameters;
  • only Env has store & restore methods.

Filing this enhancement request after chatting with @Nikokrock. The title might be too biased toward a preconceived solution; open to discussing the use-case more and seeing where else we can go.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading e3.env's existing de/serialization code and the BaseEnv.from_env, BaseEnv.copy, Env.store, and Env.restore entry points mentioned in the issue. Trace how driver data reaches test.py, then define and validate a way to preserve the needed environment attributes and testcase data across that boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.