Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #1644

Merged
merged 2 commits into from
Sep 26, 2022
Merged

Patch 1 #1644

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions Autocoders/Python/test/schematron/test_schematron.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@

@author jishii
"""

from pathlib import Path
import os
import shutil
import sys

import pexpect
from pexpect import EOF, TIMEOUT

sys.path.append(os.path.join(os.environ["BUILD_ROOT"], "Fw", "Python", "src"))
sys.path.append(os.path.join(os.environ["BUILD_ROOT"], "Gds", "src")) # Add GDS modules
build_root = Path(os.environ["BUILD_ROOT"])
sys.path.append(build_root / "Fw" / "Python" / "src")
sys.path.append(build_root / "Gds" / "src") # Add GDS modules


def test_schematron():
Expand All @@ -24,21 +25,14 @@ def test_schematron():
try:

# cd into test directory to find test files (code/test/schematron can only find files this way)
testdir = os.path.join(
os.environ["BUILD_ROOT"],
"Autocoders",
"Python",
"test",
"schematron",
"xml",
)
testdir = build_root / "Autocoders" / "Python" / "test" / "schematron" / "xml"
os.chdir(testdir)

bindir = os.path.join(os.environ["BUILD_ROOT"], "Autocoders", "Python", "bin")
bindir = build_root / "Autocoders" / "Python" / "bin"

# Autocode enum XML
p_enum = pexpect.spawn(
"python " + os.path.join(bindir, "codegen.py") + " -v Enum1EnumAi.xml"
"python " + str(bindir / "codegen.py") + " -v Enum1EnumAi.xml"
)
p_enum.expect("(?=.*Enum1 Schematron).*")
print("Enum autocoded for test cases")
Expand All @@ -52,7 +46,7 @@ def test_schematron():

# Successful test case
p_test1 = pexpect.spawn(
"python " + os.path.join(bindir, "codegen.py") + " -v TestTopologyAppAi.xml"
"python " + str(bindir / "codegen.py") + " -v TestTopologyAppAi.xml"
)
p_test1.expect(
"(?=.*Found component XML file)(?=.*Parsing Component TestComponent)(?!.*ERROR)(?!.*is not valid according to schematron).*",
Expand All @@ -63,7 +57,7 @@ def test_schematron():
# Active component without an async port
p_test2 = pexpect.spawn(
"python "
+ os.path.join(bindir, "codegen.py")
+ str(bindir / "codegen.py")
+ " -v Test2TopologyAppAi.xml"
)
p_test2.expect(
Expand All @@ -77,7 +71,7 @@ def test_schematron():
# Topology with 2 instances of the same ID
p_test3 = pexpect.spawn(
"python "
+ os.path.join(bindir, "codegen.py")
+ str(bindir / "codegen.py")
+ " -v BrokenTopologyAppAi.xml"
)
p_test3.expect("(?=.*top_uniqueness_schematron.rng)(?!.*ERROR).*", timeout=5)
Expand All @@ -91,12 +85,12 @@ def test_schematron():
# Broken imported dict
print(
"python "
+ os.path.join(bindir, "codegen.py")
+ str(bindir / "codegen.py")
+ " -v Test{}DictComponentAi.xml".format(type)
)
p_test_dict = pexpect.spawn(
"python "
+ os.path.join(bindir, "codegen.py")
+ str(bindir / "codegen.py")
+ " -v Test{}DictComponentAi.xml".format(type)
)
if type == "Cmd":
Expand Down Expand Up @@ -129,7 +123,7 @@ def test_schematron():
# Broken component xml
p_test_dict = pexpect.spawn(
"python "
+ os.path.join(bindir, "codegen.py")
+ str(bindir / "codegen.py")
+ " -v Test{}ComponentAi.xml".format(type)
)
p_test_dict.expect(
Expand Down