Skip to content

Commit

Permalink
make tests use realistic examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 7, 2023
1 parent d8da032 commit 858582d
Show file tree
Hide file tree
Showing 40 changed files with 1,169 additions and 1,195 deletions.
8 changes: 4 additions & 4 deletions docs/developer/explanations/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Expand below for the example **support module definition file**:
<details>
<summary><a>objects.ibek.support.yaml</a></summary>

.. include:: ../../../tests/samples/yaml/objects.ibek.support.yaml
.. include:: ../../../tests/samples/support/motorSim.ibek.support.yaml
:literal:

.. raw:: html
Expand Down Expand Up @@ -149,7 +149,7 @@ Click the arrows to reveal the files.
<details>
<summary><a>all.ibek.ioc.yaml</a></summary>

.. include:: ../../../tests/samples/yaml/all.ibek.ioc.yaml
.. include:: ../../../tests/samples/iocs/ibek-mo-ioc-01.yaml
:literal:

.. raw:: html
Expand All @@ -158,7 +158,7 @@ Click the arrows to reveal the files.
<details>
<summary><a>st.cmd</a></summary>

.. include:: ../../../tests/samples/outputs/all.st.cmd
.. include:: ../../../tests/samples/outputs/motorSim.st.cmd
:literal:

.. raw:: html
Expand Down Expand Up @@ -220,7 +220,7 @@ The Global Schema and example IOC instance schema are below:
<details>
<summary><a>multiple.ibek.ioc.schema.json</a></summary>

.. include:: ../../../tests/samples/schemas/multiple.ibek.ioc.schema.json
.. include:: ../../../tests/samples/schemas/single.ibek.ioc.schema.json
:literal:

.. raw:: html
Expand Down
28 changes: 16 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,41 @@ def samples():


@fixture
def yaml_defs(samples):
return samples / "yaml"
def support_defs(samples):
return samples / "support"


@fixture
def objects_classes(yaml_defs):
def ioc_defs(samples):
return samples / "iocs"


@fixture
def asyn_classes(support_defs):
# clear the entity classes to make sure there's nothing left
clear_entity_model_ids()

objects_support = get_support(yaml_defs / "objects.ibek.support.yaml")
asyn_support = get_support(support_defs / "asyn.ibek.support.yaml")

# make entity subclasses for everything defined in it
namespace = make_entity_models(objects_support)
namespace = make_entity_models(asyn_support)

# return the namespace so that callers have access to all of the
# generated dataclasses
return namespace


@fixture
def epics_support(ibek_defs):
return get_support(ibek_defs / "_global", "epics.ibek.support.yaml")


@fixture
def epics_classes(epics_support):
def motor_classes(support_defs):
# clear the entity classes to make sure there's nothing left
clear_entity_model_ids()

asyn_support = get_support(support_defs / "asyn.ibek.support.yaml")
motor_support = get_support(support_defs / "motorSim.ibek.support.yaml")

# make entity subclasses for everything defined in it
namespace = make_entity_models(epics_support)
namespace = make_entity_models(asyn_support)
namespace.extend(make_entity_models(motor_support))

# return the namespace so that callers have access to all of the
# generated dataclasses
Expand Down
28 changes: 11 additions & 17 deletions tests/generate_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,24 @@ mkdir -p outputs
set -ex

mkdir -p epics/pvi-defs
cp yaml/simple.pvi.device.yaml epics/pvi-defs/simple.pvi.device.yaml
cp support/simple.pvi.device.yaml epics/pvi-defs/simple.pvi.device.yaml

echo making the support yaml schema
ibek support generate-schema --output schemas/ibek.support.schema.json

echo making an ioc schema using object support yaml
ibek ioc generate-schema --no-ibek-defs yaml/objects.ibek.support.yaml --output schemas/objects.ibek.ioc.schema.json
echo making an ioc schema using just motorSim support yaml
ibek ioc generate-schema --no-ibek-defs support/motorSim.ibek.support.yaml --output schemas/single.ibek.ioc.schema.json

echo making an ioc schema using utils support yaml
ibek ioc generate-schema --no-ibek-defs yaml/utils.ibek.support.yaml --output schemas/utils.ibek.ioc.schema.json
echo making an ioc schema using motorSim and Asyn support yaml
ibek ioc generate-schema --no-ibek-defs support/asyn.ibek.support.yaml support/motorSim.ibek.support.yaml --output schemas/motorSim.ibek.ioc.schema.json

echo making an ioc schema using multiple support yaml files
ibek ioc generate-schema --no-ibek-defs yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --output schemas/multiple.ibek.ioc.schema.json
echo making an ioc schema using utils support yaml
ibek ioc generate-schema --no-ibek-defs support/utils.ibek.support.yaml --output schemas/utils.ibek.ioc.schema.json

echo making ioc based on objects support yaml
ibek runtime generate yaml/objects.ibek.ioc.yaml yaml/objects.ibek.support.yaml --out outputs/objects.st.cmd --db-out outputs/objects.ioc.subst
echo making ioc based on ibek-mo-ioc-01.yaml
ibek runtime generate iocs/ibek-mo-ioc-01.yaml support/asyn.ibek.support.yaml support/motorSim.ibek.support.yaml --out outputs/motorSim.st.cmd --db-out outputs/motorSim.ioc.subst
cp ${EPICS_ROOT}/opi/* outputs/

echo making ioc based on utils support yaml
ibek runtime generate yaml/utils.ibek.ioc.yaml yaml/utils.ibek.support.yaml --out outputs/utils.st.cmd --db-out outputs/utils.ioc.subst

echo making ioc based on mutiple support yaml
ibek runtime generate yaml/all.ibek.ioc.yaml yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --out outputs/all.st.cmd --db-out outputs/all.ioc.subst
cp epics/opi/* outputs/

echo making ioc with no DB based on mutiple support yaml
ibek runtime generate yaml/all.nodb.ibek.ioc.yaml yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --out outputs/all.nodb.st.cmd --db-out outputs/all.nodb.ioc.subst
ibek runtime generate iocs/utils.ibek.ioc.yaml support/utils.ibek.support.yaml --out outputs/utils.st.cmd --db-out outputs/utils.ioc.subst

File renamed without changes.
9 changes: 9 additions & 0 deletions tests/samples/iocs/bad_default.ibek.ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# yaml-language-server: $schema=../schemas/motorSim.ibek.ioc.schema.json

ioc_name: test-bad-defaults-ioc
description: an example for testing missing non-default values

entities:
# deliberately do not specify port to test failure case
- type: asyn.AsynIP
name: controllerOnePort
15 changes: 15 additions & 0 deletions tests/samples/iocs/bad_ref.ibek.ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=../schemas/motorSim.ibek.ioc.schema.json

ioc_name: test-multiple-ioc
description: demo bad object reference

entities:
- type: asyn.AsynIP
name: controllerOnePort
port: 192.168.0.55:2002

- type: motorSim.simMotorController
port: controllerOnePort_BAD_REF
controllerName: controllerOne
numAxes: 4
P: "IBEK-MO-TST-01:"
64 changes: 64 additions & 0 deletions tests/samples/iocs/ibek-mo-ioc-01.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# yaml-language-server: $schema=../schemas/motorSim.ibek.ioc.schema.json

ioc_name: "{{ ioc_yaml_file_name }}"
description: Example simulated motion IOC for Testing ibek

entities:
- type: asyn.AsynIP
name: controllerOnePort
port: 192.168.0.55:2002

- type: motorSim.simMotorController
port: controllerOnePort
controllerName: controllerOne
numAxes: 4
P: "IBEK-MO-TST-01:"

- type: motorSim.simMotorAxis
controller: controllerOne
# Use ADDR in other fields to verify jinja templating between Args
M: M{{ADDR}}
ADDR: 0
# Also use ioc_name to verify jinja templating of ioc_name
DESC: "Motor {{ADDR}} for ioc {{ioc_name}}"
home: 500

- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 1
# verify escaping for jinja templating
DESC: "Motor {{ADDR}} {% raw %} {{enclosed in escaped curly braces}} {% endraw %}"
home: 500

- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 2
# testing default DESC
home: 1500

- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 3
DESC: "Motor {{ADDR}}"
home: 2500

- type: motorSim.simMotorAxis
controller: controllerOne
M: CS_M{{ADDR}}
ADDR: 1
DESC: "CS Motor {{ADDR}}"
home: 100
CS_NUM: 3
is_cs: true

- type: motorSim.simMotorAxis
controller: controllerOne
M: CS_M{{ADDR}}
ADDR: 2
DESC: "CS Motor {{ADDR}}"
home: 100
CS_NUM: 3
is_cs: true
File renamed without changes.
37 changes: 0 additions & 37 deletions tests/samples/outputs/all.ioc.subst

This file was deleted.

21 changes: 0 additions & 21 deletions tests/samples/outputs/all.nodb.ioc.subst

This file was deleted.

30 changes: 0 additions & 30 deletions tests/samples/outputs/all.nodb.st.cmd

This file was deleted.

44 changes: 0 additions & 44 deletions tests/samples/outputs/all.st.cmd

This file was deleted.

Loading

0 comments on commit 858582d

Please sign in to comment.