-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4003: Pytest automatically picking up sweep tests
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-FileCopyrightText: © 2023 Tenstorrent Inc. | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from importlib.machinery import SourceFileLoader | ||
from tests.ttnn.sweep_tests.sweep import ( | ||
SWEEP_SOURCES_DIR, | ||
permutations, | ||
run_single_test, | ||
) | ||
from loguru import logger | ||
from dataclasses import dataclass | ||
import pytest | ||
import os | ||
|
||
|
||
@dataclass | ||
class SweepTest: | ||
file_name: str | ||
sweep_test_index: int | ||
|
||
def __str__(self): | ||
return f"{os.path.basename(self.file_name)}-{self.sweep_test_index}" | ||
|
||
|
||
sweep_tests = [] | ||
for file_name in sorted(SWEEP_SOURCES_DIR.glob("*.py")): | ||
logger.info(f"Running {file_name}") | ||
base_name = os.path.basename(file_name) | ||
base_name = os.path.splitext(base_name)[0] | ||
sweep_module = SourceFileLoader(f"sweep_module_{base_name}", str(file_name)).load_module() | ||
base_name = base_name + ".csv" | ||
for sweep_test_index, parameter_list in enumerate(permutations(sweep_module.parameters)): | ||
sweep_tests.append(SweepTest(file_name, sweep_test_index)) | ||
|
||
|
||
@pytest.mark.parametrize("sweep_test", sweep_tests, ids=str) | ||
def test_all_sweeps(device, sweep_test): | ||
status, message = run_single_test( | ||
sweep_test.file_name, | ||
sweep_test.sweep_test_index, | ||
device=device, | ||
) | ||
|
||
assert status not in {"failed", "crashed"}, f"{message}" |