From 5557ea6d687855cb24824e31bac0b2087631bae9 Mon Sep 17 00:00:00 2001 From: marsninja Date: Sat, 16 Sep 2023 13:11:02 -0400 Subject: [PATCH] Wow, I'm good, this is clever and fully functionalgit add .! --- jaclang/cli/cmds.jac | 3 +++ jaclang/cli/impl/cmds_impl.jac | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/jaclang/cli/cmds.jac b/jaclang/cli/cmds.jac index b272f52e4..f1fc4ceaa 100644 --- a/jaclang/cli/cmds.jac +++ b/jaclang/cli/cmds.jac @@ -13,6 +13,9 @@ can run(filename: str); @cmd_reg.register can enter(filename: str, entrypoint: str, args: list); +@cmd_reg.register +can <>test(filename: str); + @cmd_reg.register can ast_tool(tool: str); diff --git a/jaclang/cli/impl/cmds_impl.jac b/jaclang/cli/impl/cmds_impl.jac index 4feaca902..44da0d0cf 100644 --- a/jaclang/cli/impl/cmds_impl.jac +++ b/jaclang/cli/impl/cmds_impl.jac @@ -1,6 +1,7 @@ """Implementations for the jac command line interface.""" import:py os; import:py shutil; +import:py unittest; """Load a .jac file and return the entrypoint function.""" :a:run @@ -29,6 +30,20 @@ import:py shutil; } } +"""Load a .jac file and return the entrypoint function.""" +:a:<>test +(filename: str) { + if filename.endswith(".jac"){ + [base, mod] = os.path.split(filename); + base = './' if not base else base; + mod=mod[:-4]; + mod = __jac_import__(target=mod, base_path=base); + unittest.TextTestRunner().run(mod.__jac_suite__); + } else { + "Not a .jac file." :> print; + } +} + :a:ast_tool (tool: str) { import:py from jaclang.utils.lang_tools, AstTool;