From fabd7e0f2a53cd6f3217dee731ec332d4fb9a622 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 15:04:55 +0000 Subject: [PATCH 1/7] restore tests --- tests/samples/outputs/dlsPLC/st.cmd | 1 + tests/samples/outputs/fastVacuum/st.cmd | 1 + tests/samples/outputs/gauges/st.cmd | 1 + tests/samples/outputs/ipac-test/st.cmd | 1 + tests/samples/outputs/listarg/st.cmd | 1 + tests/samples/outputs/motorSim/st.cmd | 1 + tests/samples/outputs/quadem/st.cmd | 1 + tests/samples/outputs/technosoft/st.cmd | 1 + tests/samples/outputs/utils/st.cmd | 1 + .../schemas/dlsPLC.ibek.ioc.schema.json | 2 +- .../schemas/fastVacuum.ibek.ioc.schema.json | 2 +- .../schemas/gauges.ibek.ioc.schema.json | 2 +- .../samples/schemas/ibek.support.schema.json | 2 +- .../samples/schemas/ipac.ibek.ioc.schema.json | 2 +- .../samples/schemas/listarg.ibek.schema.json | 2 +- .../schemas/motorSim.ibek.ioc.schema.json | 2 +- .../schemas/quadem.ibek.ioc.schema.json | 2 +- .../schemas/single.ibek.ioc.schema.json | 2 +- .../schemas/technosoft.ibek.ioc.schema.json | 2 +- .../schemas/utils.ibek.ioc.schema.json | 2 +- tests/test_cli.py | 222 ++++++++++++++++++ 21 files changed, 242 insertions(+), 11 deletions(-) diff --git a/tests/samples/outputs/dlsPLC/st.cmd b/tests/samples/outputs/dlsPLC/st.cmd index b42c24cb0..c57f22c62 100644 --- a/tests/samples/outputs/dlsPLC/st.cmd +++ b/tests/samples/outputs/dlsPLC/st.cmd @@ -16,3 +16,4 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/fastVacuum/st.cmd b/tests/samples/outputs/fastVacuum/st.cmd index a583f2be3..0d92e17c3 100644 --- a/tests/samples/outputs/fastVacuum/st.cmd +++ b/tests/samples/outputs/fastVacuum/st.cmd @@ -7,3 +7,4 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/gauges/st.cmd b/tests/samples/outputs/gauges/st.cmd index d237ae084..96fc92498 100644 --- a/tests/samples/outputs/gauges/st.cmd +++ b/tests/samples/outputs/gauges/st.cmd @@ -29,3 +29,4 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/ipac-test/st.cmd b/tests/samples/outputs/ipac-test/st.cmd index 353236c8b..a474dced8 100644 --- a/tests/samples/outputs/ipac-test/st.cmd +++ b/tests/samples/outputs/ipac-test/st.cmd @@ -18,3 +18,4 @@ epicsEnvSet IPAC5 1 dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/listarg/st.cmd b/tests/samples/outputs/listarg/st.cmd index b812bdd79..0d2577396 100644 --- a/tests/samples/outputs/listarg/st.cmd +++ b/tests/samples/outputs/listarg/st.cmd @@ -31,3 +31,4 @@ Fist time vortex friend is Cat dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/motorSim/st.cmd b/tests/samples/outputs/motorSim/st.cmd index e7a5b915b..cfcb3dda8 100644 --- a/tests/samples/outputs/motorSim/st.cmd +++ b/tests/samples/outputs/motorSim/st.cmd @@ -33,3 +33,4 @@ motorSimConfigAxis(controllerOne, 3, 20000, -20000, 2500, 2500) motorSimConfigAxis(controllerOne, 1, 20000, -20000, 100, 100) # motorSimCreateAxis(controller_asyn_port_name, axis, axis_description) motorSimConfigAxis(controllerOne, 2, 20000, -20000, 100, 100) + diff --git a/tests/samples/outputs/quadem/st.cmd b/tests/samples/outputs/quadem/st.cmd index 82ef0b71b..2072c553c 100644 --- a/tests/samples/outputs/quadem/st.cmd +++ b/tests/samples/outputs/quadem/st.cmd @@ -63,3 +63,4 @@ iocInit # Increase precision of sample time for TetrAMM dbpf("BL03I-EA-XBPM-01:DRV:SampleTime_RBV.PREC", "5") + diff --git a/tests/samples/outputs/technosoft/st.cmd b/tests/samples/outputs/technosoft/st.cmd index 3468c211d..2bb78a55c 100644 --- a/tests/samples/outputs/technosoft/st.cmd +++ b/tests/samples/outputs/technosoft/st.cmd @@ -18,3 +18,4 @@ dbl dbpf("SPARC:TML:MOT:MSGRS","START") dbl + diff --git a/tests/samples/outputs/utils/st.cmd b/tests/samples/outputs/utils/st.cmd index 8bb919d9e..c824220e4 100644 --- a/tests/samples/outputs/utils/st.cmd +++ b/tests/samples/outputs/utils/st.cmd @@ -13,3 +13,4 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json index 35517c6f1..919b7670f 100644 --- a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json +++ b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json @@ -614,4 +614,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json index 430f67bd2..b23309d85 100644 --- a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json +++ b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json @@ -240,4 +240,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/gauges.ibek.ioc.schema.json b/tests/samples/schemas/gauges.ibek.ioc.schema.json index fe7c6b8ba..706bce76e 100644 --- a/tests/samples/schemas/gauges.ibek.ioc.schema.json +++ b/tests/samples/schemas/gauges.ibek.ioc.schema.json @@ -348,4 +348,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/ibek.support.schema.json b/tests/samples/schemas/ibek.support.schema.json index 4eeac9141..7a0c33430 100644 --- a/tests/samples/schemas/ibek.support.schema.json +++ b/tests/samples/schemas/ibek.support.schema.json @@ -719,4 +719,4 @@ ], "title": "Support", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/ipac.ibek.ioc.schema.json b/tests/samples/schemas/ipac.ibek.ioc.schema.json index 7c1217333..72583243e 100644 --- a/tests/samples/schemas/ipac.ibek.ioc.schema.json +++ b/tests/samples/schemas/ipac.ibek.ioc.schema.json @@ -882,4 +882,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/listarg.ibek.schema.json b/tests/samples/schemas/listarg.ibek.schema.json index 85902dfdd..ecb817a57 100644 --- a/tests/samples/schemas/listarg.ibek.schema.json +++ b/tests/samples/schemas/listarg.ibek.schema.json @@ -125,4 +125,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/motorSim.ibek.ioc.schema.json b/tests/samples/schemas/motorSim.ibek.ioc.schema.json index 24caba10a..9d213726f 100644 --- a/tests/samples/schemas/motorSim.ibek.ioc.schema.json +++ b/tests/samples/schemas/motorSim.ibek.ioc.schema.json @@ -502,4 +502,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/quadem.ibek.ioc.schema.json b/tests/samples/schemas/quadem.ibek.ioc.schema.json index e8c358b47..ab61d19e8 100644 --- a/tests/samples/schemas/quadem.ibek.ioc.schema.json +++ b/tests/samples/schemas/quadem.ibek.ioc.schema.json @@ -5365,4 +5365,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/single.ibek.ioc.schema.json b/tests/samples/schemas/single.ibek.ioc.schema.json index 7045e439b..a833c1222 100644 --- a/tests/samples/schemas/single.ibek.ioc.schema.json +++ b/tests/samples/schemas/single.ibek.ioc.schema.json @@ -297,4 +297,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/technosoft.ibek.ioc.schema.json b/tests/samples/schemas/technosoft.ibek.ioc.schema.json index 4c1db03c0..8642cd8be 100644 --- a/tests/samples/schemas/technosoft.ibek.ioc.schema.json +++ b/tests/samples/schemas/technosoft.ibek.ioc.schema.json @@ -470,4 +470,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/utils.ibek.ioc.schema.json b/tests/samples/schemas/utils.ibek.ioc.schema.json index 2fd737c24..7662b55e7 100644 --- a/tests/samples/schemas/utils.ibek.ioc.schema.json +++ b/tests/samples/schemas/utils.ibek.ioc.schema.json @@ -112,4 +112,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/test_cli.py b/tests/test_cli.py index beab7e4e3..6122e3d74 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,9 +1,231 @@ +""" +System tests that run the CLI commands and compare the output to expected +results. +""" + +import json import subprocess import sys +from pathlib import Path + +from pytest_mock import MockerFixture +import ibek.utils as utils from ibek import __version__ +from ibek.globals import ( + GLOBALS, + PVI_YAML_PATTERN, + SUPPORT_YAML_PATTERN, +) +from ibek.runtime_cmds.commands import generate +from ibek.support_cmds.commands import generate_links +from tests.conftest import run_cli def test_cli_version(): cmd = [sys.executable, "-m", "ibek", "--version"] assert subprocess.check_output(cmd).decode().strip() == __version__ + + +def test_ibek_schema(tmp_path: Path, samples: Path): + """generate the global ibek schema""" + schema_path = tmp_path / "schema.json" + run_cli("support", "generate-schema", "--output", schema_path) + expected = json.loads( + (samples / "schemas" / "ibek.support.schema.json").read_text() + ) + + actual = json.loads((schema_path).read_text()) + assert expected == actual + + +def test_single_schema(tmp_path: Path, samples: Path): + """generate schema from a support module definition yaml""" + + schema_path = tmp_path / "single.ibek.support.schema.json" + yaml_path = samples / "support" / "motorSim.ibek.support.yaml" + run_cli( + "ioc", "generate-schema", "--no-ibek-defs", yaml_path, "--output", schema_path + ) + + expected = json.loads( + (samples / "schemas" / "single.ibek.ioc.schema.json").read_text() + ) + + actual = json.loads((schema_path).read_text()) + assert expected == actual + + +def test_motor_sim_schema(tmp_path: Path, samples: Path): + """generate schema for a container with two support modules""" + + schema_combined = tmp_path / "motorSim.ibek.ioc.schema.json" + yaml_path1 = samples / "support" / "asyn.ibek.support.yaml" + yaml_path2 = samples / "support" / "motorSim.ibek.support.yaml" + run_cli( + "ioc", + "generate-schema", + "--no-ibek-defs", + yaml_path1, + yaml_path2, + "--output", + schema_combined, + ) + + expected = json.loads( + (samples / "schemas" / "motorSim.ibek.ioc.schema.json").read_text() + ) + + actual = json.loads((schema_combined).read_text()) + assert expected == actual + + +def test_build_runtime_motorSim(tmp_epics_root: Path, samples: Path): + """ + build an ioc runtime script from an IOC instance entity file + and multiple support module definition files + + Also verifies database subst file generation for multiple + entity instantiations. + """ + + generic_generate( + tmp_epics_root, + samples, + "motorSim", + ["motorSim", "asyn"], + ) + + +def test_build_utils_features(tmp_epics_root: Path, samples: Path): + """ + build an ioc runtime script to verify utils features + """ + generic_generate( + tmp_epics_root, + samples, + "utils", + ["utils"], + ) + + +def test_generate_links_ibek(samples: Path, mocker: MockerFixture): + symlink_mock = mocker.patch("ibek.support_cmds.commands.symlink_files") + + generate_links(samples / "support") + + symlink_mock.assert_any_call( + samples / "support", PVI_YAML_PATTERN, GLOBALS.PVI_DEFS + ) + symlink_mock.assert_any_call( + samples / "support", SUPPORT_YAML_PATTERN, GLOBALS.IBEK_DEFS + ) + + +def test_ipac(tmp_epics_root: Path, samples: Path): + """ + Tests that an id argument can include another argument in its default value + """ + + # reset the InterruptVector counter to its initial state (if already used) + if "InterruptVector" in utils.UTILS.variables: + utils.UTILS.variables["InterruptVector"] = 191 + + generic_generate( + tmp_epics_root, + samples, + "ipac-test", + ["ipac", "epics"], + ) + + +def test_gauges(tmp_epics_root: Path, samples: Path): + """ + Tests that an id argument can include another argument in its default value + """ + generic_generate( + tmp_epics_root, + samples, + "gauges", + ["asyn", "gauges"], + ) + + +def test_quadem(tmp_epics_root: Path, samples: Path): + """ + Tests the use of CollectionDefinitions in an IOC instance + this example uses the tetramm beam position monitor module + """ + generic_generate( + tmp_epics_root, + samples, + "quadem", + ["ADCore", "quadem"], + ) + + +def generic_generate( + epics_root: Path, samples: Path, ioc_name: str, support_names: list[str] +): + ioc_yaml = samples / "iocs" / f"{ioc_name}.ibek.ioc.yaml" + support_yamls = [ + samples / "support" / f"{name}.ibek.support.yaml" for name in support_names + ] + expected_outputs = samples / "outputs" / ioc_name + + generate(ioc_yaml, support_yamls) + + for output in expected_outputs.glob("*"): + actual = epics_root / "runtime" / output.name + if not actual.exists(): + actual = epics_root / "opi" / output.name + assert actual.exists(), "Missing output file" + assert output.read_text() == actual.read_text() + + +def test_andreas_motors(tmp_epics_root: Path, samples: Path): + """ + Motor and axis example + """ + generic_generate( + tmp_epics_root, + samples, + "technosoft", + ["asyn", "technosoft"], + ) + + +def test_list(tmp_epics_root: Path, samples: Path): + """ + Motor and axis example + """ + generic_generate( + tmp_epics_root, + samples, + "listarg", + ["listarg"], + ) + + +def test_fast_vacuum(tmp_epics_root: Path, samples: Path): + """ + Cut down copy of dlsPLC containing fast vacuum master and channel + """ + generic_generate( + tmp_epics_root, + samples, + "fastVacuum", + ["fastVacuum"], + ) + + +def test_dls_plc(tmp_epics_root: Path, samples: Path): + """ + Cut down copy of dlsPLC containing fast vacuum master and channel + """ + generic_generate( + tmp_epics_root, + samples, + "dlsPLC", + ["dlsPLC", "asyn"], + ) From 6887d93dc0af31ce7b8864c0dc2662788eefa575 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 15:06:12 +0000 Subject: [PATCH 2/7] restore CRs --- tests/samples/outputs/dlsPLC/st.cmd | 1 - tests/samples/outputs/fastVacuum/st.cmd | 1 - tests/samples/outputs/gauges/st.cmd | 1 - tests/samples/outputs/ipac-test/st.cmd | 1 - tests/samples/outputs/listarg/st.cmd | 1 - tests/samples/outputs/motorSim/st.cmd | 1 - tests/samples/outputs/quadem/st.cmd | 1 - tests/samples/outputs/technosoft/st.cmd | 1 - tests/samples/outputs/utils/st.cmd | 1 - tests/samples/schemas/dlsPLC.ibek.ioc.schema.json | 2 +- tests/samples/schemas/fastVacuum.ibek.ioc.schema.json | 2 +- tests/samples/schemas/gauges.ibek.ioc.schema.json | 2 +- tests/samples/schemas/ibek.support.schema.json | 2 +- tests/samples/schemas/ipac.ibek.ioc.schema.json | 2 +- tests/samples/schemas/listarg.ibek.schema.json | 2 +- tests/samples/schemas/motorSim.ibek.ioc.schema.json | 2 +- tests/samples/schemas/quadem.ibek.ioc.schema.json | 2 +- tests/samples/schemas/single.ibek.ioc.schema.json | 2 +- tests/samples/schemas/technosoft.ibek.ioc.schema.json | 2 +- tests/samples/schemas/utils.ibek.ioc.schema.json | 2 +- 20 files changed, 11 insertions(+), 20 deletions(-) diff --git a/tests/samples/outputs/dlsPLC/st.cmd b/tests/samples/outputs/dlsPLC/st.cmd index c57f22c62..b42c24cb0 100644 --- a/tests/samples/outputs/dlsPLC/st.cmd +++ b/tests/samples/outputs/dlsPLC/st.cmd @@ -16,4 +16,3 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/fastVacuum/st.cmd b/tests/samples/outputs/fastVacuum/st.cmd index 0d92e17c3..a583f2be3 100644 --- a/tests/samples/outputs/fastVacuum/st.cmd +++ b/tests/samples/outputs/fastVacuum/st.cmd @@ -7,4 +7,3 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/gauges/st.cmd b/tests/samples/outputs/gauges/st.cmd index 96fc92498..d237ae084 100644 --- a/tests/samples/outputs/gauges/st.cmd +++ b/tests/samples/outputs/gauges/st.cmd @@ -29,4 +29,3 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/ipac-test/st.cmd b/tests/samples/outputs/ipac-test/st.cmd index a474dced8..353236c8b 100644 --- a/tests/samples/outputs/ipac-test/st.cmd +++ b/tests/samples/outputs/ipac-test/st.cmd @@ -18,4 +18,3 @@ epicsEnvSet IPAC5 1 dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/listarg/st.cmd b/tests/samples/outputs/listarg/st.cmd index 0d2577396..b812bdd79 100644 --- a/tests/samples/outputs/listarg/st.cmd +++ b/tests/samples/outputs/listarg/st.cmd @@ -31,4 +31,3 @@ Fist time vortex friend is Cat dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/motorSim/st.cmd b/tests/samples/outputs/motorSim/st.cmd index cfcb3dda8..e7a5b915b 100644 --- a/tests/samples/outputs/motorSim/st.cmd +++ b/tests/samples/outputs/motorSim/st.cmd @@ -33,4 +33,3 @@ motorSimConfigAxis(controllerOne, 3, 20000, -20000, 2500, 2500) motorSimConfigAxis(controllerOne, 1, 20000, -20000, 100, 100) # motorSimCreateAxis(controller_asyn_port_name, axis, axis_description) motorSimConfigAxis(controllerOne, 2, 20000, -20000, 100, 100) - diff --git a/tests/samples/outputs/quadem/st.cmd b/tests/samples/outputs/quadem/st.cmd index 2072c553c..82ef0b71b 100644 --- a/tests/samples/outputs/quadem/st.cmd +++ b/tests/samples/outputs/quadem/st.cmd @@ -63,4 +63,3 @@ iocInit # Increase precision of sample time for TetrAMM dbpf("BL03I-EA-XBPM-01:DRV:SampleTime_RBV.PREC", "5") - diff --git a/tests/samples/outputs/technosoft/st.cmd b/tests/samples/outputs/technosoft/st.cmd index 2bb78a55c..3468c211d 100644 --- a/tests/samples/outputs/technosoft/st.cmd +++ b/tests/samples/outputs/technosoft/st.cmd @@ -18,4 +18,3 @@ dbl dbpf("SPARC:TML:MOT:MSGRS","START") dbl - diff --git a/tests/samples/outputs/utils/st.cmd b/tests/samples/outputs/utils/st.cmd index c824220e4..8bb919d9e 100644 --- a/tests/samples/outputs/utils/st.cmd +++ b/tests/samples/outputs/utils/st.cmd @@ -13,4 +13,3 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json index 919b7670f..35517c6f1 100644 --- a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json +++ b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json @@ -614,4 +614,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json index b23309d85..430f67bd2 100644 --- a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json +++ b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json @@ -240,4 +240,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/gauges.ibek.ioc.schema.json b/tests/samples/schemas/gauges.ibek.ioc.schema.json index 706bce76e..fe7c6b8ba 100644 --- a/tests/samples/schemas/gauges.ibek.ioc.schema.json +++ b/tests/samples/schemas/gauges.ibek.ioc.schema.json @@ -348,4 +348,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/ibek.support.schema.json b/tests/samples/schemas/ibek.support.schema.json index 7a0c33430..4eeac9141 100644 --- a/tests/samples/schemas/ibek.support.schema.json +++ b/tests/samples/schemas/ibek.support.schema.json @@ -719,4 +719,4 @@ ], "title": "Support", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/ipac.ibek.ioc.schema.json b/tests/samples/schemas/ipac.ibek.ioc.schema.json index 72583243e..7c1217333 100644 --- a/tests/samples/schemas/ipac.ibek.ioc.schema.json +++ b/tests/samples/schemas/ipac.ibek.ioc.schema.json @@ -882,4 +882,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/listarg.ibek.schema.json b/tests/samples/schemas/listarg.ibek.schema.json index ecb817a57..85902dfdd 100644 --- a/tests/samples/schemas/listarg.ibek.schema.json +++ b/tests/samples/schemas/listarg.ibek.schema.json @@ -125,4 +125,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/motorSim.ibek.ioc.schema.json b/tests/samples/schemas/motorSim.ibek.ioc.schema.json index 9d213726f..24caba10a 100644 --- a/tests/samples/schemas/motorSim.ibek.ioc.schema.json +++ b/tests/samples/schemas/motorSim.ibek.ioc.schema.json @@ -502,4 +502,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/quadem.ibek.ioc.schema.json b/tests/samples/schemas/quadem.ibek.ioc.schema.json index ab61d19e8..e8c358b47 100644 --- a/tests/samples/schemas/quadem.ibek.ioc.schema.json +++ b/tests/samples/schemas/quadem.ibek.ioc.schema.json @@ -5365,4 +5365,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/single.ibek.ioc.schema.json b/tests/samples/schemas/single.ibek.ioc.schema.json index a833c1222..7045e439b 100644 --- a/tests/samples/schemas/single.ibek.ioc.schema.json +++ b/tests/samples/schemas/single.ibek.ioc.schema.json @@ -297,4 +297,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/technosoft.ibek.ioc.schema.json b/tests/samples/schemas/technosoft.ibek.ioc.schema.json index 8642cd8be..4c1db03c0 100644 --- a/tests/samples/schemas/technosoft.ibek.ioc.schema.json +++ b/tests/samples/schemas/technosoft.ibek.ioc.schema.json @@ -470,4 +470,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/utils.ibek.ioc.schema.json b/tests/samples/schemas/utils.ibek.ioc.schema.json index 7662b55e7..2fd737c24 100644 --- a/tests/samples/schemas/utils.ibek.ioc.schema.json +++ b/tests/samples/schemas/utils.ibek.ioc.schema.json @@ -112,4 +112,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} From d7b59d051695cb2c4bd794f8b313ec56d8e02586 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 15:08:33 +0000 Subject: [PATCH 3/7] remove trailing CR --- tests/samples/outputs/dlsPLC/st.cmd | 1 + tests/samples/outputs/fastVacuum/st.cmd | 1 + tests/samples/outputs/gauges/st.cmd | 1 + tests/samples/outputs/ipac-test/st.cmd | 1 + tests/samples/outputs/listarg/st.cmd | 1 + tests/samples/outputs/motorSim/st.cmd | 1 + tests/samples/outputs/quadem/st.cmd | 1 + tests/samples/outputs/technosoft/st.cmd | 1 + tests/samples/outputs/utils/st.cmd | 1 + tests/samples/schemas/dlsPLC.ibek.ioc.schema.json | 2 +- tests/samples/schemas/fastVacuum.ibek.ioc.schema.json | 2 +- tests/samples/schemas/gauges.ibek.ioc.schema.json | 2 +- tests/samples/schemas/ibek.support.schema.json | 2 +- tests/samples/schemas/ipac.ibek.ioc.schema.json | 2 +- tests/samples/schemas/listarg.ibek.schema.json | 2 +- tests/samples/schemas/motorSim.ibek.ioc.schema.json | 2 +- tests/samples/schemas/quadem.ibek.ioc.schema.json | 2 +- tests/samples/schemas/single.ibek.ioc.schema.json | 2 +- tests/samples/schemas/technosoft.ibek.ioc.schema.json | 2 +- tests/samples/schemas/utils.ibek.ioc.schema.json | 2 +- 20 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/samples/outputs/dlsPLC/st.cmd b/tests/samples/outputs/dlsPLC/st.cmd index b42c24cb0..c57f22c62 100644 --- a/tests/samples/outputs/dlsPLC/st.cmd +++ b/tests/samples/outputs/dlsPLC/st.cmd @@ -16,3 +16,4 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/fastVacuum/st.cmd b/tests/samples/outputs/fastVacuum/st.cmd index a583f2be3..0d92e17c3 100644 --- a/tests/samples/outputs/fastVacuum/st.cmd +++ b/tests/samples/outputs/fastVacuum/st.cmd @@ -7,3 +7,4 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/gauges/st.cmd b/tests/samples/outputs/gauges/st.cmd index d237ae084..96fc92498 100644 --- a/tests/samples/outputs/gauges/st.cmd +++ b/tests/samples/outputs/gauges/st.cmd @@ -29,3 +29,4 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/ipac-test/st.cmd b/tests/samples/outputs/ipac-test/st.cmd index 353236c8b..a474dced8 100644 --- a/tests/samples/outputs/ipac-test/st.cmd +++ b/tests/samples/outputs/ipac-test/st.cmd @@ -18,3 +18,4 @@ epicsEnvSet IPAC5 1 dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/listarg/st.cmd b/tests/samples/outputs/listarg/st.cmd index b812bdd79..0d2577396 100644 --- a/tests/samples/outputs/listarg/st.cmd +++ b/tests/samples/outputs/listarg/st.cmd @@ -31,3 +31,4 @@ Fist time vortex friend is Cat dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/outputs/motorSim/st.cmd b/tests/samples/outputs/motorSim/st.cmd index e7a5b915b..cfcb3dda8 100644 --- a/tests/samples/outputs/motorSim/st.cmd +++ b/tests/samples/outputs/motorSim/st.cmd @@ -33,3 +33,4 @@ motorSimConfigAxis(controllerOne, 3, 20000, -20000, 2500, 2500) motorSimConfigAxis(controllerOne, 1, 20000, -20000, 100, 100) # motorSimCreateAxis(controller_asyn_port_name, axis, axis_description) motorSimConfigAxis(controllerOne, 2, 20000, -20000, 100, 100) + diff --git a/tests/samples/outputs/quadem/st.cmd b/tests/samples/outputs/quadem/st.cmd index 82ef0b71b..2072c553c 100644 --- a/tests/samples/outputs/quadem/st.cmd +++ b/tests/samples/outputs/quadem/st.cmd @@ -63,3 +63,4 @@ iocInit # Increase precision of sample time for TetrAMM dbpf("BL03I-EA-XBPM-01:DRV:SampleTime_RBV.PREC", "5") + diff --git a/tests/samples/outputs/technosoft/st.cmd b/tests/samples/outputs/technosoft/st.cmd index 3468c211d..2bb78a55c 100644 --- a/tests/samples/outputs/technosoft/st.cmd +++ b/tests/samples/outputs/technosoft/st.cmd @@ -18,3 +18,4 @@ dbl dbpf("SPARC:TML:MOT:MSGRS","START") dbl + diff --git a/tests/samples/outputs/utils/st.cmd b/tests/samples/outputs/utils/st.cmd index 8bb919d9e..c824220e4 100644 --- a/tests/samples/outputs/utils/st.cmd +++ b/tests/samples/outputs/utils/st.cmd @@ -13,3 +13,4 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit + diff --git a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json index 35517c6f1..919b7670f 100644 --- a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json +++ b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json @@ -614,4 +614,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json index 430f67bd2..b23309d85 100644 --- a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json +++ b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json @@ -240,4 +240,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/gauges.ibek.ioc.schema.json b/tests/samples/schemas/gauges.ibek.ioc.schema.json index fe7c6b8ba..706bce76e 100644 --- a/tests/samples/schemas/gauges.ibek.ioc.schema.json +++ b/tests/samples/schemas/gauges.ibek.ioc.schema.json @@ -348,4 +348,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/ibek.support.schema.json b/tests/samples/schemas/ibek.support.schema.json index 4eeac9141..7a0c33430 100644 --- a/tests/samples/schemas/ibek.support.schema.json +++ b/tests/samples/schemas/ibek.support.schema.json @@ -719,4 +719,4 @@ ], "title": "Support", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/ipac.ibek.ioc.schema.json b/tests/samples/schemas/ipac.ibek.ioc.schema.json index 7c1217333..72583243e 100644 --- a/tests/samples/schemas/ipac.ibek.ioc.schema.json +++ b/tests/samples/schemas/ipac.ibek.ioc.schema.json @@ -882,4 +882,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/listarg.ibek.schema.json b/tests/samples/schemas/listarg.ibek.schema.json index 85902dfdd..ecb817a57 100644 --- a/tests/samples/schemas/listarg.ibek.schema.json +++ b/tests/samples/schemas/listarg.ibek.schema.json @@ -125,4 +125,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/motorSim.ibek.ioc.schema.json b/tests/samples/schemas/motorSim.ibek.ioc.schema.json index 24caba10a..9d213726f 100644 --- a/tests/samples/schemas/motorSim.ibek.ioc.schema.json +++ b/tests/samples/schemas/motorSim.ibek.ioc.schema.json @@ -502,4 +502,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/quadem.ibek.ioc.schema.json b/tests/samples/schemas/quadem.ibek.ioc.schema.json index e8c358b47..ab61d19e8 100644 --- a/tests/samples/schemas/quadem.ibek.ioc.schema.json +++ b/tests/samples/schemas/quadem.ibek.ioc.schema.json @@ -5365,4 +5365,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/single.ibek.ioc.schema.json b/tests/samples/schemas/single.ibek.ioc.schema.json index 7045e439b..a833c1222 100644 --- a/tests/samples/schemas/single.ibek.ioc.schema.json +++ b/tests/samples/schemas/single.ibek.ioc.schema.json @@ -297,4 +297,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/technosoft.ibek.ioc.schema.json b/tests/samples/schemas/technosoft.ibek.ioc.schema.json index 4c1db03c0..8642cd8be 100644 --- a/tests/samples/schemas/technosoft.ibek.ioc.schema.json +++ b/tests/samples/schemas/technosoft.ibek.ioc.schema.json @@ -470,4 +470,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file diff --git a/tests/samples/schemas/utils.ibek.ioc.schema.json b/tests/samples/schemas/utils.ibek.ioc.schema.json index 2fd737c24..7662b55e7 100644 --- a/tests/samples/schemas/utils.ibek.ioc.schema.json +++ b/tests/samples/schemas/utils.ibek.ioc.schema.json @@ -112,4 +112,4 @@ ], "title": "NewIOC", "type": "object" -} +} \ No newline at end of file From f6515a0c3d79c461f27f2ae4617d2549414d0a2c Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 15:38:23 +0000 Subject: [PATCH 4/7] ignore extra line at end of outputs --- tests/samples/outputs/dlsPLC/st.cmd | 1 - tests/samples/outputs/fastVacuum/st.cmd | 1 - tests/samples/outputs/gauges/st.cmd | 1 - tests/samples/outputs/ipac-test/st.cmd | 1 - tests/samples/outputs/listarg/st.cmd | 1 - tests/samples/outputs/motorSim/st.cmd | 1 - tests/samples/outputs/quadem/st.cmd | 1 - tests/samples/outputs/technosoft/st.cmd | 1 - tests/samples/outputs/utils/st.cmd | 1 - tests/samples/schemas/dlsPLC.ibek.ioc.schema.json | 2 +- tests/samples/schemas/fastVacuum.ibek.ioc.schema.json | 2 +- tests/samples/schemas/gauges.ibek.ioc.schema.json | 2 +- tests/samples/schemas/ibek.support.schema.json | 2 +- tests/samples/schemas/ipac.ibek.ioc.schema.json | 2 +- tests/samples/schemas/listarg.ibek.schema.json | 2 +- tests/samples/schemas/motorSim.ibek.ioc.schema.json | 2 +- tests/samples/schemas/quadem.ibek.ioc.schema.json | 2 +- tests/samples/schemas/single.ibek.ioc.schema.json | 2 +- tests/samples/schemas/technosoft.ibek.ioc.schema.json | 2 +- tests/samples/schemas/utils.ibek.ioc.schema.json | 2 +- tests/test_cli.py | 2 +- 21 files changed, 12 insertions(+), 21 deletions(-) diff --git a/tests/samples/outputs/dlsPLC/st.cmd b/tests/samples/outputs/dlsPLC/st.cmd index c57f22c62..b42c24cb0 100644 --- a/tests/samples/outputs/dlsPLC/st.cmd +++ b/tests/samples/outputs/dlsPLC/st.cmd @@ -16,4 +16,3 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/fastVacuum/st.cmd b/tests/samples/outputs/fastVacuum/st.cmd index 0d92e17c3..a583f2be3 100644 --- a/tests/samples/outputs/fastVacuum/st.cmd +++ b/tests/samples/outputs/fastVacuum/st.cmd @@ -7,4 +7,3 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/gauges/st.cmd b/tests/samples/outputs/gauges/st.cmd index 96fc92498..d237ae084 100644 --- a/tests/samples/outputs/gauges/st.cmd +++ b/tests/samples/outputs/gauges/st.cmd @@ -29,4 +29,3 @@ asynOctetSetOutputEos("\n") dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/ipac-test/st.cmd b/tests/samples/outputs/ipac-test/st.cmd index a474dced8..353236c8b 100644 --- a/tests/samples/outputs/ipac-test/st.cmd +++ b/tests/samples/outputs/ipac-test/st.cmd @@ -18,4 +18,3 @@ epicsEnvSet IPAC5 1 dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/listarg/st.cmd b/tests/samples/outputs/listarg/st.cmd index 0d2577396..b812bdd79 100644 --- a/tests/samples/outputs/listarg/st.cmd +++ b/tests/samples/outputs/listarg/st.cmd @@ -31,4 +31,3 @@ Fist time vortex friend is Cat dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/outputs/motorSim/st.cmd b/tests/samples/outputs/motorSim/st.cmd index cfcb3dda8..e7a5b915b 100644 --- a/tests/samples/outputs/motorSim/st.cmd +++ b/tests/samples/outputs/motorSim/st.cmd @@ -33,4 +33,3 @@ motorSimConfigAxis(controllerOne, 3, 20000, -20000, 2500, 2500) motorSimConfigAxis(controllerOne, 1, 20000, -20000, 100, 100) # motorSimCreateAxis(controller_asyn_port_name, axis, axis_description) motorSimConfigAxis(controllerOne, 2, 20000, -20000, 100, 100) - diff --git a/tests/samples/outputs/quadem/st.cmd b/tests/samples/outputs/quadem/st.cmd index 2072c553c..82ef0b71b 100644 --- a/tests/samples/outputs/quadem/st.cmd +++ b/tests/samples/outputs/quadem/st.cmd @@ -63,4 +63,3 @@ iocInit # Increase precision of sample time for TetrAMM dbpf("BL03I-EA-XBPM-01:DRV:SampleTime_RBV.PREC", "5") - diff --git a/tests/samples/outputs/technosoft/st.cmd b/tests/samples/outputs/technosoft/st.cmd index 2bb78a55c..3468c211d 100644 --- a/tests/samples/outputs/technosoft/st.cmd +++ b/tests/samples/outputs/technosoft/st.cmd @@ -18,4 +18,3 @@ dbl dbpf("SPARC:TML:MOT:MSGRS","START") dbl - diff --git a/tests/samples/outputs/utils/st.cmd b/tests/samples/outputs/utils/st.cmd index c824220e4..8bb919d9e 100644 --- a/tests/samples/outputs/utils/st.cmd +++ b/tests/samples/outputs/utils/st.cmd @@ -13,4 +13,3 @@ ioc_registerRecordDeviceDriver pdbbase dbLoadRecords /epics/runtime/ioc.db iocInit - diff --git a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json index 919b7670f..35517c6f1 100644 --- a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json +++ b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json @@ -614,4 +614,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json index b23309d85..430f67bd2 100644 --- a/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json +++ b/tests/samples/schemas/fastVacuum.ibek.ioc.schema.json @@ -240,4 +240,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/gauges.ibek.ioc.schema.json b/tests/samples/schemas/gauges.ibek.ioc.schema.json index 706bce76e..fe7c6b8ba 100644 --- a/tests/samples/schemas/gauges.ibek.ioc.schema.json +++ b/tests/samples/schemas/gauges.ibek.ioc.schema.json @@ -348,4 +348,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/ibek.support.schema.json b/tests/samples/schemas/ibek.support.schema.json index 7a0c33430..4eeac9141 100644 --- a/tests/samples/schemas/ibek.support.schema.json +++ b/tests/samples/schemas/ibek.support.schema.json @@ -719,4 +719,4 @@ ], "title": "Support", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/ipac.ibek.ioc.schema.json b/tests/samples/schemas/ipac.ibek.ioc.schema.json index 72583243e..7c1217333 100644 --- a/tests/samples/schemas/ipac.ibek.ioc.schema.json +++ b/tests/samples/schemas/ipac.ibek.ioc.schema.json @@ -882,4 +882,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/listarg.ibek.schema.json b/tests/samples/schemas/listarg.ibek.schema.json index ecb817a57..85902dfdd 100644 --- a/tests/samples/schemas/listarg.ibek.schema.json +++ b/tests/samples/schemas/listarg.ibek.schema.json @@ -125,4 +125,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/motorSim.ibek.ioc.schema.json b/tests/samples/schemas/motorSim.ibek.ioc.schema.json index 9d213726f..24caba10a 100644 --- a/tests/samples/schemas/motorSim.ibek.ioc.schema.json +++ b/tests/samples/schemas/motorSim.ibek.ioc.schema.json @@ -502,4 +502,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/quadem.ibek.ioc.schema.json b/tests/samples/schemas/quadem.ibek.ioc.schema.json index ab61d19e8..e8c358b47 100644 --- a/tests/samples/schemas/quadem.ibek.ioc.schema.json +++ b/tests/samples/schemas/quadem.ibek.ioc.schema.json @@ -5365,4 +5365,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/single.ibek.ioc.schema.json b/tests/samples/schemas/single.ibek.ioc.schema.json index a833c1222..7045e439b 100644 --- a/tests/samples/schemas/single.ibek.ioc.schema.json +++ b/tests/samples/schemas/single.ibek.ioc.schema.json @@ -297,4 +297,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/technosoft.ibek.ioc.schema.json b/tests/samples/schemas/technosoft.ibek.ioc.schema.json index 8642cd8be..4c1db03c0 100644 --- a/tests/samples/schemas/technosoft.ibek.ioc.schema.json +++ b/tests/samples/schemas/technosoft.ibek.ioc.schema.json @@ -470,4 +470,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/samples/schemas/utils.ibek.ioc.schema.json b/tests/samples/schemas/utils.ibek.ioc.schema.json index 7662b55e7..2fd737c24 100644 --- a/tests/samples/schemas/utils.ibek.ioc.schema.json +++ b/tests/samples/schemas/utils.ibek.ioc.schema.json @@ -112,4 +112,4 @@ ], "title": "NewIOC", "type": "object" -} \ No newline at end of file +} diff --git a/tests/test_cli.py b/tests/test_cli.py index 6122e3d74..fbb5fdc88 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -180,7 +180,7 @@ def generic_generate( if not actual.exists(): actual = epics_root / "opi" / output.name assert actual.exists(), "Missing output file" - assert output.read_text() == actual.read_text() + assert output.read_text().strip() == actual.read_text().strip() def test_andreas_motors(tmp_epics_root: Path, samples: Path): From ea498bacded815afb233bb740764b8388333cf5c Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 15:59:46 +0000 Subject: [PATCH 5/7] raise ValueError for Jinja failures --- src/ibek/utils.py | 5 ++--- tests/samples/iocs/DLS8515.ibek.ioc.yaml | 2 +- tests/test_cli.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ibek/utils.py b/src/ibek/utils.py index a474132a0..11c287cfe 100644 --- a/src/ibek/utils.py +++ b/src/ibek/utils.py @@ -104,9 +104,8 @@ def render(self, context: Any, template_text: Any) -> str: ioc_yaml_file_name=self.file_name, ioc_name=self.ioc_name, ) - except Exception: - print(f"ERROR RENDERING TEMPLATE:\n{template_text}") - raise + except Exception as e: + raise ValueError(f"Error rendering template:\n{template_text}") from e def render_map(self, context: Any, map: Mapping[str, str | None]) -> dict[str, str]: """ diff --git a/tests/samples/iocs/DLS8515.ibek.ioc.yaml b/tests/samples/iocs/DLS8515.ibek.ioc.yaml index 2074cab29..b996849e7 100644 --- a/tests/samples/iocs/DLS8515.ibek.ioc.yaml +++ b/tests/samples/iocs/DLS8515.ibek.ioc.yaml @@ -11,7 +11,7 @@ entities: - type: ipac.Hy8002 name: BLX4I-VA-IOC-01-Slot4 - # interrupt_vector: Vec1 + interrupt_vector: Vec1 slot: 4 - type: DLS8515.DLS8515 diff --git a/tests/test_cli.py b/tests/test_cli.py index fbb5fdc88..678efbdc2 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -229,3 +229,15 @@ def test_dls_plc(tmp_epics_root: Path, samples: Path): "dlsPLC", ["dlsPLC", "asyn"], ) + + +def test_dls8515(tmp_epics_root: Path, samples: Path): + """ + Cut down copy of dlsPLC containing fast vacuum master and channel + """ + generic_generate( + tmp_epics_root, + samples, + "DLS8515", + ["DLS8515", "ipac", "epics"], + ) From b91cc6621acac5c973c2446009b4c4d69b1a308c Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 16:12:06 +0000 Subject: [PATCH 6/7] add better error handling on referenced objects --- tests/test_cli.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 678efbdc2..ce81f6f07 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -8,6 +8,7 @@ import sys from pathlib import Path +import pytest from pytest_mock import MockerFixture import ibek.utils as utils @@ -235,9 +236,12 @@ def test_dls8515(tmp_epics_root: Path, samples: Path): """ Cut down copy of dlsPLC containing fast vacuum master and channel """ - generic_generate( - tmp_epics_root, - samples, - "DLS8515", - ["DLS8515", "ipac", "epics"], - ) + with pytest.raises(ValueError) as ctx: + generic_generate( + tmp_epics_root, + samples, + "DLS8515", + ["DLS8515", "ipac", "epics"], + ) + + assert "`ipac.Hy8002`.interrupt_vector" in str(ctx.value) From cee51bc5d73ec0eca6410d43908cf1d3241c3d47 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Feb 2025 16:20:58 +0000 Subject: [PATCH 7/7] include jinja error text in value error --- src/ibek/utils.py | 4 +++- tests/test_unit.py | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ibek/utils.py b/src/ibek/utils.py index 11c287cfe..572f70dd9 100644 --- a/src/ibek/utils.py +++ b/src/ibek/utils.py @@ -105,7 +105,9 @@ def render(self, context: Any, template_text: Any) -> str: ioc_name=self.ioc_name, ) except Exception as e: - raise ValueError(f"Error rendering template:\n{template_text}") from e + raise ValueError( + f"Error rendering template:\n{template_text}\nError:{e}" + ) from e def render_map(self, context: Any, map: Mapping[str, str | None]) -> dict[str, str]: """ diff --git a/tests/test_unit.py b/tests/test_unit.py index 5698aa951..a5d5caf8e 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -6,7 +6,6 @@ import shutil from pathlib import Path -import jinja2 import pytest from ibek.commands import semver_compare @@ -87,11 +86,11 @@ def test_strict(): assert text == "giles of age 59" my_template = "{{ person.name ~ ' of age ' ~ height }}" - with pytest.raises(jinja2.exceptions.UndefinedError): + with pytest.raises(ValueError): text = UTILS.render({"person": p}, my_template) my_template = "{{ person.name ~ ' of age ' ~ person.height }}" - with pytest.raises(jinja2.exceptions.UndefinedError): + with pytest.raises(ValueError): text = UTILS.render({"person": p}, my_template)