diff options
Diffstat (limited to '')
| -rw-r--r-- | .github/workflows/ci.yml | 12 | ||||
| -rwxr-xr-x | test/stress/test.py | 79 |
2 files changed, 64 insertions, 27 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55283e1..2009740 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 - with: - submodules: recursive - name: Set up clang-format uses: egor-tensin/setup-clang@v2 with: @@ -23,6 +21,16 @@ jobs: uses: egor-tensin/clang-format@v1 with: version: 22 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.x' + - name: Run black + uses: psf/black@stable + with: + # > Please note that the --check flag is required so that the + # > workflow fails if Black finds files that need to be formatted. + options: --check --verbose --skip-string-normalization build: strategy: diff --git a/test/stress/test.py b/test/stress/test.py index 2701db3..2e6b252 100755 --- a/test/stress/test.py +++ b/test/stress/test.py @@ -83,8 +83,9 @@ class ExprGen: @staticmethod def gen_expression(): - numof_operators = random.randrange(ExprGen._MIN_NUMOF_OPERATORS, - ExprGen._MAX_NUMOF_OPERATORS + 1) + numof_operators = random.randrange( + ExprGen._MIN_NUMOF_OPERATORS, ExprGen._MAX_NUMOF_OPERATORS + 1 + ) expr = '' for _ in range(numof_operators): expr += f"{ExprGen._random_number()} {ExprGen._random_operator()} " @@ -153,14 +154,22 @@ def _run_client(client, stdin): with _logging(): cmd = client.get_command_line() with timer('Client invocation'): - result = subprocess.run(cmd, stdout=PIPE, stderr=PIPE, input=stdin, - universal_newlines=True, check=True) + result = subprocess.run( + cmd, + stdout=PIPE, + stderr=PIPE, + input=stdin, + universal_newlines=True, + check=True, + ) return Output(result.stdout) def _run_clients(numof_clients, client, stdin): with Pool(numof_clients) as pool: - results = pool.starmap(_run_client, [(client, stdin) for _ in range(numof_clients)]) + results = pool.starmap( + _run_client, [(client, stdin) for _ in range(numof_clients)] + ) if len(results) != numof_clients: raise RuntimeError(f'expected {numof_clients} results, got {len(results)}') return results @@ -203,26 +212,45 @@ def _parse_args(argv=None): argv = sys.argv[1:] parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.RawDescriptionHelpFormatter) + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter + ) - parser.add_argument('--host', '-H', metavar='HOST', - default=Client.DEFAULT_HOST, - help='server host') - parser.add_argument('--port', '-p', metavar='PORT', - type=int, default=Client.DEFAULT_PORT, - help='server port') - parser.add_argument('--processes', '-n', metavar='N', - dest='numof_processes', - type=_parse_positive_int, default=1, - help='number of processes') - parser.add_argument('--expressions', '-e', metavar='N', - dest='numof_expressions', - type=_parse_positive_int, default=1, - help='number of expressions') - parser.add_argument('--client', '-c', metavar='PATH', - default=Client.DEFAULT_PATH, - help='path to the client executable') + parser.add_argument( + '--host', '-H', metavar='HOST', default=Client.DEFAULT_HOST, help='server host' + ) + parser.add_argument( + '--port', + '-p', + metavar='PORT', + type=int, + default=Client.DEFAULT_PORT, + help='server port', + ) + parser.add_argument( + '--processes', + '-n', + metavar='N', + dest='numof_processes', + type=_parse_positive_int, + default=1, + help='number of processes', + ) + parser.add_argument( + '--expressions', + '-e', + metavar='N', + dest='numof_expressions', + type=_parse_positive_int, + default=1, + help='number of expressions', + ) + parser.add_argument( + '--client', + '-c', + metavar='PATH', + default=Client.DEFAULT_PATH, + help='path to the client executable', + ) return parser.parse_args(argv) @@ -232,7 +260,8 @@ def _logging(): logging.basicConfig( format='%(asctime)s | %(levelname)s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S%z', - level=logging.DEBUG) + level=logging.DEBUG, + ) try: yield except Exception as e: |
