Skip to content

Commit

Permalink
rever lua-hello changes in lieu of hardcoded execption
Browse files Browse the repository at this point in the history
  • Loading branch information
charles37 committed Nov 15, 2024
1 parent 55271ff commit d0081c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
12 changes: 11 additions & 1 deletion hwci/boards/tockloader_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ def flash_app(self, app_path):

# Build the app using absolute paths
logging.info(f"Building app: {app_name}")
subprocess.run(["make", f"TOCK_TARGETS={self.arch}"], cwd=app_dir, check=True)
if app_name != "lua-hello":
subprocess.run(
["make", f"TOCK_TARGETS={self.arch}"], cwd=app_dir, check=True
)
else:
# if the app is lua-hello, we need to build the libtock-c submodule first so we need to change directory
# into the libtock-c directory so it knows we are in a git repostiory
self.change_directory(libtock_c_dir)
subprocess.run(
["make", f"TOCK_TARGETS={self.arch}"], cwd=app_dir, check=True
)

tab_file = os.path.join(app_dir, "build", f"{app_name}.tab")
if not os.path.exists(tab_file):
Expand Down
43 changes: 1 addition & 42 deletions hwci/tests/lua-hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,6 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
# Copyright Tock Contributors 2024.

import logging
import os
import subprocess
from utils.test_helpers import WaitForConsoleMessageTest
from utils.test_helpers import OneshotTest


class LuaHelloTest(WaitForConsoleMessageTest):
def __init__(self):
super().__init__(["lua-hello"], "Hello from Lua!")

def test(self, board):
# Initialize and update Lua submodule before running the test
libtock_c_dir = os.path.join(
os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
),
"libtock-c",
)
lua_dir = os.path.join(libtock_c_dir, "examples", "lua-hello")

try:
# Initialize the Lua submodule
logging.info("Initializing Lua submodule...")
subprocess.run(
["git", "submodule", "init", "--", "lua"], cwd=lua_dir, check=True
)

# Update the Lua submodule
logging.info("Updating Lua submodule...")
subprocess.run(["git", "submodule", "update"], cwd=lua_dir, check=True)

# Run the parent class's test method
super().test(board)

except subprocess.CalledProcessError as e:
logging.error(f"Failed to initialize/update Lua submodule: {e}")
raise
except Exception as e:
logging.error(f"Error during test execution: {e}")
raise


test = LuaHelloTest()
test = WaitForConsoleMessageTest(["lua-hello"], "Hello from Lua!")

0 comments on commit d0081c9

Please sign in to comment.