OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # Import before super_mox to keep valid references. | 8 # Import before super_mox to keep valid references. |
9 from os import rename | 9 from os import rename |
10 from shutil import rmtree | 10 from shutil import rmtree |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 ] | 520 ] |
521 | 521 |
522 # If you add a member, be sure to add the relevant test! | 522 # If you add a member, be sure to add the relevant test! |
523 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) | 523 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) |
524 | 524 |
525 def testRevertMissing(self): | 525 def testRevertMissing(self): |
526 if not self.enabled: | 526 if not self.enabled: |
527 return | 527 return |
528 options = self.Options() | 528 options = self.Options() |
529 file_path = gclient_scm.os.path.join(self.base_path, 'a') | 529 file_path = gclient_scm.os.path.join(self.base_path, 'a') |
530 gclient_scm.os.remove(file_path) | |
531 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 530 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
532 relpath=self.relpath) | 531 relpath=self.relpath) |
533 file_list = [] | 532 file_list = [] |
| 533 scm.update(options, None, file_list) |
| 534 gclient_scm.os.remove(file_path) |
| 535 file_list = [] |
534 scm.revert(options, self.args, file_list) | 536 scm.revert(options, self.args, file_list) |
535 self.assertEquals(file_list, [file_path]) | 537 self.assertEquals(file_list, [file_path]) |
536 file_list = [] | 538 file_list = [] |
537 scm.diff(options, self.args, file_list) | 539 scm.diff(options, self.args, file_list) |
538 self.assertEquals(file_list, []) | 540 self.assertEquals(file_list, []) |
539 | 541 |
540 def testRevertNone(self): | 542 def testRevertNone(self): |
541 if not self.enabled: | 543 if not self.enabled: |
542 return | 544 return |
543 options = self.Options() | 545 options = self.Options() |
544 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 546 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
545 relpath=self.relpath) | 547 relpath=self.relpath) |
546 file_list = [] | 548 file_list = [] |
| 549 scm.update(options, None, file_list) |
| 550 file_list = [] |
547 scm.revert(options, self.args, file_list) | 551 scm.revert(options, self.args, file_list) |
548 self.assertEquals(file_list, []) | 552 self.assertEquals(file_list, []) |
549 self.assertEquals(scm.revinfo(options, self.args, None), | 553 self.assertEquals(scm.revinfo(options, self.args, None), |
550 '069c602044c5388d2d15c3f875b057c852003458') | 554 'a7142dc9f0009350b96a11f372b6ea658592aa95') |
551 | 555 |
552 | 556 |
553 def testRevertModified(self): | 557 def testRevertModified(self): |
554 if not self.enabled: | 558 if not self.enabled: |
555 return | 559 return |
556 options = self.Options() | 560 options = self.Options() |
| 561 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 562 relpath=self.relpath) |
| 563 file_list = [] |
| 564 scm.update(options, None, file_list) |
557 file_path = gclient_scm.os.path.join(self.base_path, 'a') | 565 file_path = gclient_scm.os.path.join(self.base_path, 'a') |
558 open(file_path, 'a').writelines('touched\n') | 566 open(file_path, 'a').writelines('touched\n') |
559 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | |
560 relpath=self.relpath) | |
561 file_list = [] | 567 file_list = [] |
562 scm.revert(options, self.args, file_list) | 568 scm.revert(options, self.args, file_list) |
563 self.assertEquals(file_list, [file_path]) | 569 self.assertEquals(file_list, [file_path]) |
564 file_list = [] | 570 file_list = [] |
565 scm.diff(options, self.args, file_list) | 571 scm.diff(options, self.args, file_list) |
566 self.assertEquals(file_list, []) | 572 self.assertEquals(file_list, []) |
567 self.assertEquals(scm.revinfo(options, self.args, None), | 573 self.assertEquals(scm.revinfo(options, self.args, None), |
568 '069c602044c5388d2d15c3f875b057c852003458') | 574 'a7142dc9f0009350b96a11f372b6ea658592aa95') |
569 | 575 |
570 def testRevertNew(self): | 576 def testRevertNew(self): |
571 if not self.enabled: | 577 if not self.enabled: |
572 return | 578 return |
573 options = self.Options() | 579 options = self.Options() |
| 580 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 581 relpath=self.relpath) |
| 582 file_list = [] |
| 583 scm.update(options, None, file_list) |
574 file_path = gclient_scm.os.path.join(self.base_path, 'c') | 584 file_path = gclient_scm.os.path.join(self.base_path, 'c') |
575 f = open(file_path, 'w') | 585 f = open(file_path, 'w') |
576 f.writelines('new\n') | 586 f.writelines('new\n') |
577 f.close() | 587 f.close() |
578 Popen(['git', 'add', 'c'], stdout=PIPE, | 588 Popen(['git', 'add', 'c'], stdout=PIPE, |
579 stderr=STDOUT, cwd=self.base_path).communicate() | 589 stderr=STDOUT, cwd=self.base_path).communicate() |
580 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | |
581 relpath=self.relpath) | |
582 file_list = [] | 590 file_list = [] |
583 scm.revert(options, self.args, file_list) | 591 scm.revert(options, self.args, file_list) |
584 self.assertEquals(file_list, [file_path]) | 592 self.assertEquals(file_list, [file_path]) |
585 file_list = [] | 593 file_list = [] |
586 scm.diff(options, self.args, file_list) | 594 scm.diff(options, self.args, file_list) |
587 self.assertEquals(file_list, []) | 595 self.assertEquals(file_list, []) |
588 self.assertEquals(scm.revinfo(options, self.args, None), | 596 self.assertEquals(scm.revinfo(options, self.args, None), |
589 '069c602044c5388d2d15c3f875b057c852003458') | 597 'a7142dc9f0009350b96a11f372b6ea658592aa95') |
590 | 598 |
591 def testStatusNew(self): | 599 def testStatusNew(self): |
592 if not self.enabled: | 600 if not self.enabled: |
593 return | 601 return |
594 options = self.Options() | 602 options = self.Options() |
595 file_path = gclient_scm.os.path.join(self.base_path, 'a') | 603 file_path = gclient_scm.os.path.join(self.base_path, 'a') |
596 open(file_path, 'a').writelines('touched\n') | 604 open(file_path, 'a').writelines('touched\n') |
597 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 605 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
598 relpath=self.relpath) | 606 relpath=self.relpath) |
599 file_list = [] | 607 file_list = [] |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 relpath=self.relpath) | 726 relpath=self.relpath) |
719 rev_info = scm.revinfo(options, (), None) | 727 rev_info = scm.revinfo(options, (), None) |
720 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 728 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
721 | 729 |
722 | 730 |
723 if __name__ == '__main__': | 731 if __name__ == '__main__': |
724 import unittest | 732 import unittest |
725 unittest.main() | 733 unittest.main() |
726 | 734 |
727 # vim: ts=2:sw=2:tw=80:et: | 735 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |