Added test command.
This commit is contained in:
parent
782065ec10
commit
0d4a17fb26
3 changed files with 33 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from typing import TextIO
|
from typing import TextIO
|
||||||
|
|
||||||
from osdk.model import ComponentManifest, TargetManifest, Props
|
from osdk.model import Props
|
||||||
from osdk.ninja import Writer
|
from osdk.ninja import Writer
|
||||||
from osdk.logger import Logger
|
from osdk.logger import Logger
|
||||||
from osdk.context import Context, contextFor
|
from osdk.context import Context, contextFor
|
||||||
|
@ -122,7 +122,6 @@ class Paths:
|
||||||
|
|
||||||
def buildAll(targetSpec: str) -> Paths:
|
def buildAll(targetSpec: str) -> Paths:
|
||||||
context = contextFor(targetSpec)
|
context = contextFor(targetSpec)
|
||||||
target = context.target
|
|
||||||
|
|
||||||
shell.mkdir(context.builddir())
|
shell.mkdir(context.builddir())
|
||||||
ninjaPath = os.path.join(context.builddir(), "build.ninja")
|
ninjaPath = os.path.join(context.builddir(), "build.ninja")
|
||||||
|
@ -137,3 +136,23 @@ def buildAll(targetSpec: str) -> Paths:
|
||||||
os.path.join(context.builddir(), "lib"),
|
os.path.join(context.builddir(), "lib"),
|
||||||
os.path.join(context.builddir(), "obj")
|
os.path.join(context.builddir(), "obj")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def testAll(targetSpec: str):
|
||||||
|
context = contextFor(targetSpec)
|
||||||
|
|
||||||
|
shell.mkdir(context.builddir())
|
||||||
|
ninjaPath = os.path.join(context.builddir(), "build.ninja")
|
||||||
|
|
||||||
|
with open(ninjaPath, "w") as f:
|
||||||
|
gen(f, context)
|
||||||
|
|
||||||
|
shell.exec(f"ninja", "-v", "-f", ninjaPath, "all")
|
||||||
|
|
||||||
|
for instance in context.enabledInstances():
|
||||||
|
if instance.isLib():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if instance.id().endswith("-tests"):
|
||||||
|
print(f"Running {instance.id()}")
|
||||||
|
shell.exec(instance.outfile(context))
|
||||||
|
|
|
@ -49,6 +49,15 @@ def runCmd(args: Args):
|
||||||
cmds += [Cmd("r", "run", "Run the target", runCmd)]
|
cmds += [Cmd("r", "run", "Run the target", runCmd)]
|
||||||
|
|
||||||
|
|
||||||
|
def testCmd(args: Args):
|
||||||
|
targetSpec = cast(str, args.consumeOpt(
|
||||||
|
"target", "host-" + shell.uname().machine))
|
||||||
|
builder.testAll(targetSpec)
|
||||||
|
|
||||||
|
|
||||||
|
cmds += [Cmd("t", "test", "Run all test targets", testCmd)]
|
||||||
|
|
||||||
|
|
||||||
def debugCmd(args: Args):
|
def debugCmd(args: Args):
|
||||||
targetSpec = cast(str, args.consumeOpt(
|
targetSpec = cast(str, args.consumeOpt(
|
||||||
"target", "host-" + shell.uname().machine))
|
"target", "host-" + shell.uname().machine))
|
||||||
|
|
|
@ -36,6 +36,9 @@ class ComponentInstance:
|
||||||
self.sources = sources
|
self.sources = sources
|
||||||
self.resolved = resolved
|
self.resolved = resolved
|
||||||
|
|
||||||
|
def id(self) -> str:
|
||||||
|
return self.manifest.id
|
||||||
|
|
||||||
def isLib(self):
|
def isLib(self):
|
||||||
return self.manifest.type == Type.LIB
|
return self.manifest.type == Type.LIB
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue