• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

Révision0631b1df53f4594dc96c49ec0d3ea3fcc04c3145 (tree)
l'heure2023-10-06 22:47:43
AuteurAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Message de Log

Refacored RPy/Jinja-templates: split-off _header castle/writers/RPy/

Change Summary

Modification

diff -r 216c1ade7641 -r 0631b1df53f4 Makefile
--- a/Makefile Fri Oct 06 13:38:08 2023 +0200
+++ b/Makefile Fri Oct 06 15:47:43 2023 +0200
@@ -17,11 +17,11 @@
1717 pytst/writers/RPy/test_0_templating.py \
1818 pytst/writers/RPy/test_1_EventIndexes.py \
1919 pytst/writers/RPy/test_2_ProtocolDataStructures.py \
20+ pytst/aigr/test_2c_GenericProtocols.py \
21+ pytst/aigr/test_0_aid.py \
2022 #
2123 rPY_CURRENT = \
2224 pytst/writers/RPy/test_99_SieveMoats.py \
23- pytst/aigr/test_2c_GenericProtocols.py \
24- pytst/aigr/test_0_aid.py \
2525 #
2626 CC2CPy_TODO = \
2727 pytst/writers/RPy/test_999.py \
diff -r 216c1ade7641 -r 0631b1df53f4 TestDoubles/AIGR/protocols/Sieve.py
--- a/TestDoubles/AIGR/protocols/Sieve.py Fri Oct 06 13:38:08 2023 +0200
+++ b/TestDoubles/AIGR/protocols/Sieve.py Fri Oct 06 15:47:43 2023 +0200
@@ -3,7 +3,6 @@
33 from castle.aigr.aid import TypedParameter
44 from castle.aigr import EventProtocol, Event
55
6-import pytest
76
87 StartSieve = EventProtocol('StartSieve',
98 events=[
diff -r 216c1ade7641 -r 0631b1df53f4 castle/writers/RPy/templates/_header.jinja2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/castle/writers/RPy/templates/_header.jinja2 Fri Oct 06 15:47:43 2023 +0200
@@ -0,0 +1,5 @@
1+# -*- python -*-
2+# Generated (R)Python file
3+# (C) Albert Mietus, 2023. Part of Castle/CCastle project
4+
5+
diff -r 216c1ade7641 -r 0631b1df53f4 castle/writers/RPy/templates/moat.jinja2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/castle/writers/RPy/templates/moat.jinja2 Fri Oct 06 15:47:43 2023 +0200
@@ -0,0 +1,1 @@
1+
diff -r 216c1ade7641 -r 0631b1df53f4 castle/writers/RPy/templates/protocol.jinja2
--- a/castle/writers/RPy/templates/protocol.jinja2 Fri Oct 06 13:38:08 2023 +0200
+++ b/castle/writers/RPy/templates/protocol.jinja2 Fri Oct 06 15:47:43 2023 +0200
@@ -1,19 +1,15 @@
1-# -*- python -*-
2-# Generated (R)Python file
3-# (C) Albert Mietus, 2023. Part of Castle/CCastle project
4-
5-# {#- Hi-lock: (( "{{\\(.*\\)}}" (1 'font-lock-constant-face prepend))) -#}
6-# {#- Hi-lock: (( "{%\\(.*\\)%}" (1 'font-lock-function-name-face prepend))) -#}
7-# {#- Hi-lock: (( "{#\\(.*\\)\\(#\\)}" (1 'font-lock-preprocessor-face prepend))) -#} {# regexp: '(#)}' to escape for rendering
8-# {#- Hi-lock: (( "{[{%#]\\|[}%#]}" (0 'markdown-language-keyword-face prepend))) -#}
9-# {#- Hi-lock: end -- highlight jinja2 #}
10-
11-{% import "CastleMacros.jinja2" as m1 %}
1+{% include '_header.jinja2' %}
2+{#--------------------------#}
3+{% import 'CastleMacros.jinja2' as m1 %}
124 {#------------------------------------#}
135
6+
147 {# These imports are static #}
8+{% block static_imports %}
9+####
1510 from CC import buildin
1611 from CC import base
12+{% endblock %}
1713
1814 {% block imports %}
1915 #Put the Castle/generated imports here
diff -r 216c1ade7641 -r 0631b1df53f4 pytst/writers/RPy/__init__.py
--- a/pytst/writers/RPy/__init__.py Fri Oct 06 13:38:08 2023 +0200
+++ b/pytst/writers/RPy/__init__.py Fri Oct 06 15:47:43 2023 +0200
@@ -14,6 +14,10 @@
1414 return RPy.Template("protocol.jinja2")
1515
1616 @pytest.fixture
17+def T_Moat():
18+ return RPy.Template("moat.jinja2")
19+
20+@pytest.fixture
1721 def T_EventIndexes():
1822 return RPy.Template("EventIndexes.jinja2")
1923
@@ -69,9 +73,7 @@
6973
7074 def _gen_matcher(aigr_mock, td, save_file, out):
7175 logger.debug("---------- out: (%s)----------\n%s", aigr_mock, out)
72- if save_file:
73- td.write_gen(out)
74-
76+ if save_file: td.write_gen(out)
7577 ref = td.read_ref()
7678 try:
7779 #assert line by line: gives better feedback when they do not match
@@ -85,7 +87,14 @@
8587 @pytest.fixture
8688 def generatedProtocol_verifier(T_Protocol):
8789 def protocol_matcher(aigr_mock, td, save_file=False):
88- out = T_Protocol.render(protocols=(aigr_mock,))
90+ out = T_Protocol.render(protocols=(aigr_mock,))
91+ return _gen_matcher(aigr_mock, td, save_file, out)
92+ return protocol_matcher
93+
94+@pytest.fixture
95+def generatedMoat_verifier(T_Moat):
96+ def protocol_matcher(aigr_mock, td, save_file=False):
97+ out = T_Moat.render(XXXX=aigr_mock)
8998 return _gen_matcher(aigr_mock, td, save_file, out)
9099 return protocol_matcher
91100
diff -r 216c1ade7641 -r 0631b1df53f4 pytst/writers/RPy/test_99_SieveMoats.py
--- a/pytst/writers/RPy/test_99_SieveMoats.py Fri Oct 06 13:38:08 2023 +0200
+++ b/pytst/writers/RPy/test_99_SieveMoats.py Fri Oct 06 15:47:43 2023 +0200
@@ -3,9 +3,9 @@
33
44 import pytest
55 from TestDoubles.AIGR.protocols import Sieve
6-from . import TstDoubles, generatedProtocol_verifier, T_Protocol
7-##Note: T_Protocol is used in generatedProtocol_verifier; but need to be in this scope
8-
6+from . import TstDoubles, generatedProtocol_verifier, generatedMoat_verifier
7+##Note: T_* are used in **_verifier; but need to be in this scope (or pytest can't find it)
8+from . import T_Protocol, T_Moat
99
1010 SAVE_FILE=True
1111
@@ -18,4 +18,7 @@
1818 def test_03_SimpleSieve(generatedProtocol_verifier):
1919 generatedProtocol_verifier(aigr_mock=Sieve.SimpleSieve, td=TstDoubles('protocols/SimpleSieve'), save_file=SAVE_FILE)
2020
21+@pytest.mark.fail
22+def test_04_SieveMoat(generatedMoat_verifier):
23+ assert False
2124