[ews-build] Add unit tests for UnApplyPatchIfRequired
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 18:02:55 +0000 (18:02 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 18:02:55 +0000 (18:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197197

Reviewed by Lucas Forschler.

* BuildSlaveSupport/ews-build/steps_unittest.py:
(TestUnApplyPatchIfRequired):
(TestUnApplyPatchIfRequired.test_success):
(TestUnApplyPatchIfRequired.test_failure):
(TestUnApplyPatchIfRequired.test_skip):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-build/steps_unittest.py
Tools/ChangeLog

index 98a3146..1f0f03b 100644 (file)
@@ -866,6 +866,48 @@ class TestCleanWorkingDirectory(BuildStepMixinAdditions, unittest.TestCase):
         return self.runStep()
 
 
+class TestUnApplyPatchIfRequired(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(UnApplyPatchIfRequired())
+        self.setProperty('patchFailedToBuild', True)
+        self.expectHidden(False)
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['Tools/Scripts/clean-webkit'],
+                        )
+            + 0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Unapplied patch')
+        return self.runStep()
+
+    def test_failure(self):
+        self.setupStep(UnApplyPatchIfRequired())
+        self.setProperty('patchFailedToBuild', True)
+        self.expectHidden(False)
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['Tools/Scripts/clean-webkit'],
+                        )
+            + ExpectShell.log('stdio', stdout='Unexpected failure.')
+            + 2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Unapplied patch (failure)')
+        return self.runStep()
+
+    def test_skip(self):
+        self.setupStep(UnApplyPatchIfRequired())
+        self.expectHidden(True)
+        self.expectOutcome(result=SKIPPED, state_string='Unapplied patch (skipped)')
+        return self.runStep()
+
+
 class TestArchiveBuiltProduct(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True
index 34ec15e..102e5d6 100644 (file)
@@ -1,5 +1,18 @@
 2019-04-23  Aakash Jain  <aakash_jain@apple.com>
 
+        [ews-build] Add unit tests for UnApplyPatchIfRequired
+        https://bugs.webkit.org/show_bug.cgi?id=197197
+
+        Reviewed by Lucas Forschler.
+
+        * BuildSlaveSupport/ews-build/steps_unittest.py:
+        (TestUnApplyPatchIfRequired):
+        (TestUnApplyPatchIfRequired.test_success):
+        (TestUnApplyPatchIfRequired.test_failure):
+        (TestUnApplyPatchIfRequired.test_skip):
+
+2019-04-23  Aakash Jain  <aakash_jain@apple.com>
+
         [ews-build] Add unit tests for CleanWorkingDirectory
         https://bugs.webkit.org/show_bug.cgi?id=197195