mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Print not measured files at the end
This commit is contained in:
parent
b447f62bda
commit
b7b18d2f51
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@ -1057,6 +1057,7 @@ jobs:
|
|||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
- name: Combine files into one
|
- name: Combine files into one
|
||||||
run: |
|
run: |
|
||||||
|
ls -alh pytest-execution-time-report-*
|
||||||
jq 'reduce inputs as $item ({}; . *= $item)' \
|
jq 'reduce inputs as $item ({}; . *= $item)' \
|
||||||
pytest-execution-time-report-${{ env.DEFAULT_PYTHON }}-*.json \
|
pytest-execution-time-report-${{ env.DEFAULT_PYTHON }}-*.json \
|
||||||
> pytest-execution-time-report-${{ env.DEFAULT_PYTHON }}.json
|
> pytest-execution-time-report-${{ env.DEFAULT_PYTHON }}.json
|
||||||
|
@ -34,6 +34,18 @@ class Bucket:
|
|||||||
return " ".join(self._paths) + "\n"
|
return " ".join(self._paths) + "\n"
|
||||||
|
|
||||||
|
|
||||||
|
def add_not_measured_files(
|
||||||
|
test: TestFolder | TestFile, not_measured_files: set[TestFile]
|
||||||
|
) -> None:
|
||||||
|
"""Add not measured files to test folder."""
|
||||||
|
if test.not_measured_files > 0:
|
||||||
|
if isinstance(test, TestFolder):
|
||||||
|
for child in test.children.values():
|
||||||
|
add_not_measured_files(child, not_measured_files)
|
||||||
|
else:
|
||||||
|
not_measured_files.add(test)
|
||||||
|
|
||||||
|
|
||||||
class BucketHolder:
|
class BucketHolder:
|
||||||
"""Class to hold buckets."""
|
"""Class to hold buckets."""
|
||||||
|
|
||||||
@ -55,6 +67,7 @@ class BucketHolder:
|
|||||||
x.not_measured_files,
|
x.not_measured_files,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
not_measured_tests = set()
|
||||||
bucket_sort_keys = (
|
bucket_sort_keys = (
|
||||||
lambda x: (x.not_measured_files, x.approx_execution_time),
|
lambda x: (x.not_measured_files, x.approx_execution_time),
|
||||||
lambda x: (x.approx_execution_time, x.not_measured_files),
|
lambda x: (x.approx_execution_time, x.not_measured_files),
|
||||||
@ -82,6 +95,10 @@ class BucketHolder:
|
|||||||
< avg_not_measured_files
|
< avg_not_measured_files
|
||||||
) or is_file:
|
) or is_file:
|
||||||
smallest_bucket.add(tests)
|
smallest_bucket.add(tests)
|
||||||
|
add_not_measured_files(
|
||||||
|
tests,
|
||||||
|
not_measured_tests,
|
||||||
|
)
|
||||||
# Ensure all files from the same folder are in the same bucket
|
# Ensure all files from the same folder are in the same bucket
|
||||||
# to ensure that syrupy correctly identifies unused snapshots
|
# to ensure that syrupy correctly identifies unused snapshots
|
||||||
if is_file:
|
if is_file:
|
||||||
@ -94,12 +111,21 @@ class BucketHolder:
|
|||||||
f"Adding {other_test.path} tests to same bucket due syrupy"
|
f"Adding {other_test.path} tests to same bucket due syrupy"
|
||||||
)
|
)
|
||||||
smallest_bucket.add(other_test)
|
smallest_bucket.add(other_test)
|
||||||
|
add_not_measured_files(
|
||||||
|
tests,
|
||||||
|
not_measured_tests,
|
||||||
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
# verify that all tests are added to a bucket
|
# verify that all tests are added to a bucket
|
||||||
if not test_folder.added_to_bucket:
|
if not test_folder.added_to_bucket:
|
||||||
raise ValueError("Not all tests are added to a bucket")
|
raise ValueError("Not all tests are added to a bucket")
|
||||||
|
|
||||||
|
if not_measured_tests:
|
||||||
|
print(f"Found {len(not_measured_tests)} not measured test files: ")
|
||||||
|
for test in sorted(not_measured_tests, key=lambda x: x.path):
|
||||||
|
print(f"- {test.path}")
|
||||||
|
|
||||||
def create_ouput_file(self) -> None:
|
def create_ouput_file(self) -> None:
|
||||||
"""Create output file."""
|
"""Create output file."""
|
||||||
with Path("pytest_buckets.txt").open("w") as file:
|
with Path("pytest_buckets.txt").open("w") as file:
|
||||||
@ -136,6 +162,10 @@ class TestFile:
|
|||||||
"""Return if greater than."""
|
"""Return if greater than."""
|
||||||
return self.approx_execution_time > other.approx_execution_time
|
return self.approx_execution_time > other.approx_execution_time
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
"""Return hash."""
|
||||||
|
return hash(self.path)
|
||||||
|
|
||||||
|
|
||||||
class TestFolder:
|
class TestFolder:
|
||||||
"""Class to hold a folder with test files and folders."""
|
"""Class to hold a folder with test files and folders."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user