Skip to content

Commit

Permalink
TestShard should be able to pickle reference_files
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268379

Reviewed by Jonathan Bedard.

Previously, this got the type of reference_files wrong. This happened to
work because we never actually set it anywhere. However, on a local
branch where it is set this unsurprisingly fails.

* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner.py:
(TestShard.pack):
* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
(LayoutTestRunnerTests.test_interrupt_if_at_failure_limits): Drive-by, remove dead variable.
(ShardTests):
(ShardTests.test_pickle):

Canonical link: https://commits.webkit.org/273789@main
  • Loading branch information
gsnedders committed Jan 30, 2024
1 parent bb825e0 commit 5d4d9c7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,14 @@ def pack(self, test_input, mutation=None):
expected_image_path=mutation(test_input.test.expected_image_path),
expected_checksum_path=mutation(test_input.test.expected_checksum_path),
expected_audio_path=mutation(test_input.test.expected_audio_path),
reference_files=None if test_input.test.reference_files is None else [mutation(file) for file in test_input.test.reference_files],
reference_files=(
None
if test_input.test.reference_files is None
else tuple(
(ref_type, mutation(ref_path))
for ref_type, ref_path in test_input.test.reference_files
)
),
is_http_test=test_input.test.is_http_test,
is_websocket_test=test_input.test.is_websocket_test,
is_wpt_test=test_input.test.is_wpt_test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,25 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import pickle
import unittest

from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.systemhost_mock import MockSystemHost
from webkitpy.layout_tests import run_webkit_tests
from webkitpy.layout_tests.controllers.layout_test_runner import LayoutTestRunner, Sharder, TestRunInterruptedException
from webkitpy.layout_tests.models import test_expectations
from webkitpy.layout_tests.models import test_failures
from webkitpy.layout_tests.controllers.layout_test_runner import (
LayoutTestRunner,
Sharder,
TestRunInterruptedException,
TestShard,
)
from webkitpy.layout_tests.models import test_expectations, test_failures
from webkitpy.layout_tests.models.test import Test
from webkitpy.layout_tests.models.test_input import TestInput
from webkitpy.layout_tests.models.test_results import TestResult
from webkitpy.layout_tests.models.test_run_results import TestRunResults
from webkitpy.port.test import TestPort


TestExpectations = test_expectations.TestExpectations


Expand Down Expand Up @@ -117,7 +121,7 @@ def test_interrupt_if_at_failure_limits(self):

runner._options.exit_after_n_crashes_or_timeouts = None
runner._options.exit_after_n_failures = 10
exception = self.assertRaises(TestRunInterruptedException, runner._interrupt_if_at_failure_limits, run_results)
self.assertRaises(TestRunInterruptedException, runner._interrupt_if_at_failure_limits, run_results)

def test_update_summary_with_result(self):
# Reftests expected to be image mismatch should be respected when pixel_tests=False.
Expand Down Expand Up @@ -322,3 +326,34 @@ def test_shard_every_file(self):
('.', ['dom/html/level2/html/HTMLAnchorElement03.html']),
('.', ['ietestcenter/Javascript/11.1.5_4-4-c-1.html']),
('.', ['dom/html/level2/html/HTMLAnchorElement06.html'])])


class ShardTests(unittest.TestCase):
def test_pickle(self):
tests = [
Test(
test_path="failures/expected/empty.html",
),
Test(
test_path="failures/expected/mismatch.html",
reference_files=(
(
"!=",
"/test.checkout/LayoutTests/failures/expected/mismatch-expected-mismatch.html",
),
),
),
Test(
test_path="failures/expected/image.html",
expected_text_path="/test.checkout/LayoutTests/failures/expected/image-expected.txt",
expected_image_path="/test.checkout/LayoutTests/failures/expected/image-expected.png",
),
Test(
test_path="failures/expected/audio.html",
expected_audio_path="/test.checkout/LayoutTests/failures/expected/audio-expected.wav",
),
]
test_inputs = [TestInput(t) for t in tests]
shard = TestShard("failures/expected", test_inputs)
reloaded_shard = pickle.loads(pickle.dumps(shard))
self.assertEqual(shard, reloaded_shard)

0 comments on commit 5d4d9c7

Please sign in to comment.