diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-29 10:56:17 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-29 10:56:17 +0200 |
| commit | 5784ad5c7c8216e0334766cdfbf11f9bdbd4b001 (patch) | |
| tree | abbd4168e38fc65c1ea691156d13a40366e03cd8 /src/main.py | |
| parent | 56125041e0720754651ae561f68eb186b71b331a (diff) | |
| download | philosophers_test-5784ad5c7c8216e0334766cdfbf11f9bdbd4b001.tar.gz philosophers_test-5784ad5c7c8216e0334766cdfbf11f9bdbd4b001.tar.bz2 philosophers_test-5784ad5c7c8216e0334766cdfbf11f9bdbd4b001.zip | |
Added fail log file, Added pager after run
Diffstat (limited to 'src/main.py')
| -rwxr-xr-x | src/main.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/main.py b/src/main.py index dcee90e..17d8b52 100755 --- a/src/main.py +++ b/src/main.py @@ -32,9 +32,23 @@ from test import Test def main(): parser = argparse.ArgumentParser(description="Philosophers test") - parser.add_argument("-p", "--philo", help="Id of the philosophers to test ", - required=True, type=int, choices=[1, 2, 3]) - parser.add_argument("-b", "--build", help="Build and exit") + parser.add_argument( + "-p", "--philo", + help="Id of the philosophers to test ", + required=True, + type=int, + choices=[1, 2, 3] + ) + parser.add_argument( + "-b", "--build", + help="Build and exit", + action="store_true" + ) + parser.add_argument( + "-g", "--pager", + help="Open {} in a pager after the test".format(config.RESULT_FILE), + action="store_true" + ) args = parser.parse_args() if config.BUILD_BEFORE or args.build: @@ -81,8 +95,16 @@ def main(): Test(10, 100, 100, 10) Test(10, 200, 10, 10, infinite=True) - Test.run_all(config.PHILO_EXEC_PATHS[0]) - # print("yo") + try: + Test.run_all(config.PHILO_EXEC_PATHS[0]) + except KeyboardInterrupt: + pass + finally: + Test.write_failed() + if args.pager: + subprocess.run([*config.PAGER_CMD, config.RESULT_FILE]) + else: + print("Read {} for more information".format(config.RESULT_FILE)) if __name__ == "__main__": |
