Skip to content

Commit

Permalink
Merge pull request #4329 from OpenBB-finance/feature/resp_integration
Browse files Browse the repository at this point in the history
Make integration tests more responsive
  • Loading branch information
jmaslek authored Feb 24, 2023
2 parents 39d7cc6 + b95d6f8 commit 8770814
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions openbb_terminal/core/integration_tests/integration_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from multiprocessing.pool import Pool
from pathlib import Path
from traceback import FrameSummary, extract_tb, format_list
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple

from openbb_terminal.core.config.paths import (
MISCELLANEOUS_DIRECTORY,
Expand Down Expand Up @@ -353,6 +353,7 @@ def run_test_files(
verbose: bool = False,
special_arguments: Optional[Dict[str, str]] = None,
subprocesses: Optional[int] = None,
ordered: bool = False,
) -> Tuple[int, int, Dict[str, Dict[str, Any]], float]:
"""Runs the test scripts and returns the fails dictionary
Expand All @@ -366,6 +367,8 @@ def run_test_files(
The special arguments to use in the scripts
subprocesses: Optional[int]
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order
Returns
-------
Expand Down Expand Up @@ -410,8 +413,10 @@ def run_test_files(
if extra:
chunksize += 1

runner: Callable = pool.imap if ordered else pool.imap_unordered

for i, result in enumerate(
pool.imap(
runner(
partial(
run_test,
verbose=verbose,
Expand Down Expand Up @@ -531,6 +536,7 @@ def run_test_session(
special_arguments: Optional[Dict[str, str]] = None,
verbose: bool = False,
subprocesses: Optional[int] = None,
ordered: bool = False,
):
"""Run the integration test session
Expand All @@ -552,11 +558,13 @@ def run_test_session(
Whether or not to print the output of the scripts
subprocesses
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order.
"""
console.print(to_section_title("integration test session starts"), style="bold")
test_files = collect_test_files(path_list, skip_list)
n_successes, n_failures, fails, seconds = run_test_files(
test_files, verbose, special_arguments, subprocesses
test_files, verbose, special_arguments, subprocesses, ordered
)
display_failures(fails)
display_summary(fails, n_successes, n_failures, seconds)
Expand Down Expand Up @@ -645,6 +653,14 @@ def parse_args_and_run():
action="store_true",
default=False,
)
parser.add_argument(
"-o",
"--ordered",
help="Multiprocessing is not ordered by default. Use this flag to run the tests in order.",
dest="ordered",
action="store_true",
default=False,
)
for arg in special_arguments_values:
parser.add_argument(
f"--{arg}",
Expand Down Expand Up @@ -680,6 +696,7 @@ def parse_args_and_run():
special_arguments=special_args_dict,
verbose=ns_parser.verbose,
subprocesses=ns_parser.subprocesses,
ordered=ns_parser.ordered,
)


Expand Down

0 comments on commit 8770814

Please sign in to comment.