mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-17 19:34:13 +02:00
798010cc83
Scripts get conductorPropertyByUuid() and setConductorPropertyByUuid(), the wire named by its uuid (conductorUuids()) rather than by a symbol's terminal. A change goes to every wire at the wire's potential, as setConductorProperty() does. When those wires are all on folios not built, none is numbered by a formula, and what changes in each is what a .qetz database holds in its own columns (number, function, voltage, colour and section of the wire, cable, bus), it goes through the project database: the store and the conductor rows, undoable by uuid. The potential is followed in the database (projectDataBase::potentialWires(): through wire ends, folio reports and terminal blocks, as Conductor::relatedPotentialConductors() follows it; a terminal block that isolates its terminals answers nothing). Building a wire takes its change (Conductor::fromXml()); a .qetz save writes it in the database, the folio file copied; a folio written from its XML gets it there; a .qet builds. Anything else builds the folio, as before. tst_lazyfolios: every wire's potential from the database = as followed, 1 342 of 1 342 (industrial, eager and from a .qetz); a cable set by uuid on a 14-wire potential builds no folio, reaches every wire, saves as when built, undoes, shows once built (fails when building ignores the change, and when the .qetz writer does). The test's run limit is raised (500 s -> 1 500 s, ctest 1 800 s): under load it ran past 500 s. ctest 96/96 both ways. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.8 KiB
Python
61 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Link the lazy folios integration probe using an existing Ninja app build.
|
|
|
|
Reuses app objects without duplicating the app or introducing a core-library
|
|
refactor. No application source or existing executable is replaced. The
|
|
generated manifest, probe binary, reports and export fixtures stay in build/.
|
|
"""
|
|
import argparse
|
|
import pathlib
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--build', required=True)
|
|
parser.add_argument('--binary', required=True)
|
|
parser.add_argument('--source', required=True)
|
|
parser.add_argument('--fixture', required=True)
|
|
args = parser.parse_args()
|
|
build = pathlib.Path(args.build).resolve()
|
|
binary = pathlib.Path(args.binary).resolve()
|
|
source = pathlib.Path(args.source).resolve()
|
|
fixture = pathlib.Path(args.fixture).resolve()
|
|
manifest = (build / 'build.ninja').read_text(encoding='utf-8')
|
|
match = re.search(r'^build (\S*?/sources/main\.cpp\.(?:obj|o)):', manifest, re.MULTILINE)
|
|
if not match:
|
|
sys.exit('Cannot find the application main object in the Ninja build.')
|
|
main_object = match.group(1)
|
|
probe_object = main_object.replace('main.cpp.', 'lazy_folios_probe.cpp.')
|
|
probe_binary = binary.with_name('lazy_folios_probe' + binary.suffix)
|
|
def escape(path):
|
|
return pathlib.Path(path).as_posix().replace('$', '$$').replace(':', '$:').replace(' ', '$ ')
|
|
main_source = source.parents[2] / 'sources' / 'main.cpp'
|
|
manifest = manifest.replace(main_object, probe_object)
|
|
manifest = manifest.replace(escape(main_source), escape(source))
|
|
if binary.suffix:
|
|
manifest = manifest.replace(binary.name, probe_binary.name)
|
|
else:
|
|
old_target = escape(binary.name if binary.parent == build else binary)
|
|
new_target = escape(probe_binary.name if probe_binary.parent == build else probe_binary)
|
|
manifest = manifest.replace('build ' + old_target + ':', 'build ' + new_target + ':')
|
|
old_file = binary.name if binary.parent == build else binary.as_posix()
|
|
new_file = probe_binary.name if probe_binary.parent == build else probe_binary.as_posix()
|
|
manifest = re.sub(r'^ TARGET_FILE = ' + re.escape(old_file) + r'$',
|
|
' TARGET_FILE = ' + new_file, manifest, flags=re.MULTILINE)
|
|
probe_manifest = build / 'lazy-folios-probe.ninja'
|
|
probe_manifest.write_text(manifest, encoding='utf-8')
|
|
ninja = shutil.which('ninja')
|
|
if not ninja:
|
|
sys.exit('Ninja is required for the integration probe.')
|
|
target = probe_binary.name if probe_binary.parent == build else str(probe_binary)
|
|
subprocess.run([ninja, '-C', str(build), '-f', probe_manifest.name, target], check=True)
|
|
output = build / 'lazy-folios'
|
|
output.mkdir(exist_ok=True)
|
|
report = output / 'results.txt'
|
|
result = subprocess.run([str(probe_binary), str(fixture), str(report), str(output)], timeout=1500)
|
|
if report.exists():
|
|
print(report.read_text(encoding='utf-8', errors='replace'))
|
|
sys.exit(result.returncode)
|