Skip to content

pyTest failure fix for .wbo merge

Yusuke Tanaka requested to merge Suke/rocolib_old:main into ci

A bug fix that makes pytest fail

pyTest failed upon .makeoutput specifically at .wbo file creation. IOStream was closed in to3D function, which should have been kept open for later use in the handler. Originally pyTest was done only against py_component and now all library components makeoutput are tested.

pytest fails for Foil with an unrelated bug.

test_library.py::test_rebuild FAILED [ 2%]C:\Users\yusuk\OneDrive - UCLA IT Services\LEMUR_UCLA\Roco2SimRocolib\env\Scripts\python.exe: can't find 'main' module in 'C:\Users\yusuk\OneDrive' C:\Users\yusuk\OneDrive - UCLA IT Services\LEMUR_UCLA\Roco2SimRocolib\env\Scripts\python.exe: can't find 'main' module in 'C:\Users\yusuk\OneDrive' C:\Users\yusuk\OneDrive - UCLA IT Services\LEMUR_UCLA\Roco2SimRocolib\env\Scripts\python.exe: can't find 'main' module in 'C:\Users\yusuk\OneDrive' C:\Users\yusuk\OneDrive - UCLA IT Services\LEMUR_UCLA\Roco2SimRocolib\env\Scripts\python.exe: can't find 'main' module in 'C:\Users\yusuk\OneDrive' C:\Users\yusuk\OneDrive - UCLA IT Services\LEMUR_UCLA\Roco2SimRocolib\env\Scripts\python.exe: can't find 'main' module in 'C:\Users\yusuk\OneDrive'

test_library.py:5 (test_rebuild) c = None

def test_rebuild(c = None):
    if c:
        rebuildComponent(c)
    else:
      rebuild()

test_library.py:10:


..\library__init__.py:67: in rebuild success &= rebuildComponent(c, built, throw=False) ..\library__init__.py:90: in rebuildComponent rebuildComponent(sc, built)


c = 'Foil', built = {'BoatBase', 'Cabin', 'Canoe', 'Catamaran', 'Foil'} throw = True

def rebuildComponent(c, built=None, throw=True):
    if c not in yamlComponents:
        log.debug(f"{c} is not a yaml Component, skipping")
        return True
    if built is None:
        built = set()
    if c in built:
        log.debug(f"{c} has been rebuilt, skipping")
        return True

    definition = load_yaml(c)
    src = definition.get("source", None)
    success = True
    if src:
        log.info(f"Rebuilding {c} from {ROCOLIB_LIBRARY}/{src}...")

        subcomponents = set()
        for k, v in definition.get("subcomponents", dict()).items():
            subcomponents.add(v["classname"])
        for sc in subcomponents:
            rebuildComponent(sc, built)

        # XXX TODO: Test to make sure we don't call this script and then infinitely recurse!
        log.debug(f"Calling os.system: % python {ROCOLIB_LIBRARY}/{src}")
        if system(f"python {ROCOLIB_LIBRARY}/{src}"):
            success = False

        built.add(c)
        log.debug(repr(built))
        log.debug(f"Done rebuilding {c}.")
    if throw:
      assert success, f"Error rebuilding {c}, check stdout/stderr for details"

E AssertionError: Error rebuilding Foil, check stdout/stderr for details

..\library__init__.py:101: AssertionError

Edited by Yusuke Tanaka

Merge request reports