diff options
-rw-r--r-- | Biz/Dragons/main.py | 31 | ||||
-rw-r--r-- | Biz/Que/Client.py | 19 | ||||
-rw-r--r-- | Omni/Bild.hs | 44 |
3 files changed, 58 insertions, 36 deletions
diff --git a/Biz/Dragons/main.py b/Biz/Dragons/main.py index f85d9e7..e9df03f 100644 --- a/Biz/Dragons/main.py +++ b/Biz/Dragons/main.py @@ -225,27 +225,32 @@ def guard_git(repo: Repo) -> None: sys.exit(f"error: not a git repository: {repo}") -if __name__ == "__main__": - ARGS = get_args() - if ARGS.test: +def main() -> None: + """Entrypoint.""" + args = get_args() + if args.test: sys.stdout.write("ok") sys.exit() - logging.basicConfig(stream=sys.stderr, level=ARGS.verbosity.upper()) + logging.basicConfig(stream=sys.stderr, level=args.verbosity.upper()) logging.debug("starting") - os.chdir(pathlib.Path(ARGS.repo).resolve()) + os.chdir(pathlib.Path(args.repo).resolve()) - guard_git(ARGS.repo) + guard_git(args.repo) # if no active users provided, load from .mailmap - if ARGS.active_users == [] and pathlib.Path(".mailmap").exists(): - ARGS.active_users = mailmap_users() + if args.active_users == [] and pathlib.Path(".mailmap").exists(): + args.active_users = mailmap_users() # collect data - REPO = Repo(ARGS.ignored, ARGS.active_users) + repo = Repo(args.ignored, args.active_users) # print data - REPO.print_score() - REPO.print_blackholes(full=ARGS.blackholes) - REPO.print_liabilities(full=ARGS.liabilities) - REPO.print_stale(full=ARGS.stale) + repo.print_score() + repo.print_blackholes(full=args.blackholes) + repo.print_liabilities(full=args.liabilities) + repo.print_stale(full=args.stale) + + +if __name__ == "__main__": + main() diff --git a/Biz/Que/Client.py b/Biz/Que/Client.py index 9620c5e..ccbb980 100644 --- a/Biz/Que/Client.py +++ b/Biz/Que/Client.py @@ -215,21 +215,26 @@ def get_args() -> argparse.Namespace: return cli.parse_args() -if __name__ == "__main__": - ARGV = get_args() - if ARGV.test: +def main() -> None: + """Entrypoint.""" + argv = get_args() + if argv.test: sys.stdout.write("ok\n") sys.exit() - if ARGV.debug: + if argv.debug: logging.basicConfig( format="%(asctime)s: %(levelname)s: %(message)s", level=logging.DEBUG, datefmt="%Y.%m.%d..%H.%M.%S", ) try: - if ARGV.infile: - send(ARGV) + if argv.infile: + send(argv) else: - recv(ARGV) + recv(argv) except KeyboardInterrupt: sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/Omni/Bild.hs b/Omni/Bild.hs index 60253c0..e6c9152 100644 --- a/Omni/Bild.hs +++ b/Omni/Bild.hs @@ -882,22 +882,33 @@ isSuccess Exit.ExitSuccess = True isSuccess _ = False test :: Bool -> Target -> IO (Exit.ExitCode, ByteString) -test loud Target {..} = case compiler of - Ghc -> do - root <- Env.getEnv "CODEROOT" - run - <| Proc - { loud = loud, - cmd = root </> outToPath out, - args = ["test"], - ns = namespace, - onFailure = Log.fail ["test", nschunk namespace] >> Log.br, - onSuccess = Log.pass ["test", nschunk namespace] >> Log.br - } - _ -> - Log.warn ["test", nschunk namespace, "unavailable"] - >> Log.br - >> pure (Exit.ExitFailure 1, mempty) +test loud Target {..} = + Env.getEnv "CODEROOT" + +> \root -> case compiler of + Ghc -> + Proc + { loud = loud, + cmd = root </> outToPath out, + args = ["test"], + ns = namespace, + onFailure = Log.fail ["test", nschunk namespace] >> Log.br, + onSuccess = Log.pass ["test", nschunk namespace] >> Log.br + } + |> run + CPython -> + Proc + { loud = loud, + cmd = root </> outToPath out, + args = ["test"], + ns = namespace, + onFailure = Log.fail ["test", nschunk namespace] >> Log.br, + onSuccess = Log.pass ["test", nschunk namespace] >> Log.br + } + |> run + _ -> + Log.warn ["test", nschunk namespace, "unavailable"] + >> Log.br + >> pure (Exit.ExitFailure 1, mempty) build :: Bool -> Bool -> Int -> Int -> Analysis -> IO [Exit.ExitCode] build andTest loud jobs cpus analysis = @@ -908,6 +919,7 @@ build andTest loud jobs cpus analysis = Meta.Bin _ -> Log.info ["bild", "nix", "python", nschunk namespace] >> nixBuild loud jobs cpus target + +> (\r -> (isSuccess (fst r) && andTest) ?: (test loud target, pure r)) _ -> Log.info ["bild", "nix", "python", nschunk namespace, "cannot build library"] >> pure (Exit.ExitSuccess, mempty) |