Bug 1832284 - Fix rooting hazard in JSObject::swap r=sfink
[gecko.git] / python / mozversioncontrol / test / test_update.py
blob91c7469ee530af60c1bde19d1b7b0d5685fa7bcf
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from subprocess import CalledProcessError
7 import mozunit
8 import pytest
10 from mozversioncontrol import get_repository_object
12 STEPS = {
13 "hg": [
14 """
15 echo "bar" >> bar
16 echo "baz" > foo
17 hg commit -m "second commit"
18 """,
19 """
20 echo "foobar" > foo
21 """,
23 "git": [
24 """
25 echo "bar" >> bar
26 echo "baz" > foo
27 git add *
28 git commit -m "second commit"
29 """,
30 """
31 echo "foobar" > foo
32 """,
37 def test_update(repo):
38 vcs = get_repository_object(repo.dir)
39 rev0 = vcs.head_ref
41 repo.execute_next_step()
42 rev1 = vcs.head_ref
43 assert rev0 != rev1
45 if repo.vcs == "hg":
46 vcs.update(".~1")
47 else:
48 vcs.update("HEAD~1")
49 assert vcs.head_ref == rev0
51 vcs.update(rev1)
52 assert vcs.head_ref == rev1
54 # Update should fail with dirty working directory.
55 repo.execute_next_step()
56 with pytest.raises(CalledProcessError):
57 vcs.update(rev0)
59 assert vcs.head_ref == rev1
62 if __name__ == "__main__":
63 mozunit.main()