Skip to content

Commit

Permalink
Force state pickling to use a specific protocol. Add a unit test exer…
Browse files Browse the repository at this point in the history
…cising pickling. (#15611)
  • Loading branch information
jdm authored and jgraham committed Mar 1, 2019
1 parent ce50d58 commit 107b55b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions tools/wptrunner/wptrunner/tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from io import BytesIO

from .. import metadata, manifestupdate
from ..update import WPTUpdate
from ..update.base import StepRunner, Step
from mozlog import structuredlog, handlers, formatters

sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir))
Expand Down Expand Up @@ -701,3 +703,29 @@ def test_update_leak_total_4():

assert not new_manifest.is_empty
assert new_manifest.has_key("leak-threshold") is False


class TestStep(Step):
def create(self, state):
test_id = "/path/to/test.htm"
tests = [("path/to/test.htm", [test_id], "testharness", "")]
state.foo = create_test_manifest(tests)

class UpdateRunner(StepRunner):
steps = [TestStep]

def test_update_pickle():
logger = structuredlog.StructuredLogger("expected_test")
args = {
"test_paths": {
"/": {"tests_path": ""},
},
"abort": False,
"continue": False,
"sync": False,
}
args2 = args.copy()
args2["abort"] = True
wptupdate = WPTUpdate(logger, **args2)
wptupdate = WPTUpdate(logger, runner_cls=UpdateRunner, **args)
wptupdate.run()
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/update/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def push(self, init_values):
def save(self):
"""Write the state to disk"""
with open(self.filename, "w") as f:
pickle.dump(self, f)
pickle.dump(self, f, 2)

def is_empty(self):
return len(self._data) == 1 and self._data[0] == {}
Expand Down

0 comments on commit 107b55b

Please sign in to comment.