Skip wptrunner builders when calculate the subset of builders to fetch

When calculate the subset of builders to fetch result, only one is
picked for those have same fallback paths. As wptrunner builders are
using linux-trusty as port name, they will shadow linux-blink-rel and
each other.
Do not include wptrunner builders when calculate the subset of
builders to fetch, instead always add wptrunner builders to the end.

Bug: 1205249
Change-Id: I60642808a601a0aec510ea7707fd701a920a125c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872542
Commit-Queue: Weizhong Xia <weizhong@google.com>
Reviewed-by: Luke Z <lpz@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#879097}
diff --git a/third_party/blink/tools/blinkpy/tool/commands/rebaseline.py b/third_party/blink/tools/blinkpy/tool/commands/rebaseline.py
index 223d05a..ec9a2dd 100644
--- a/third_party/blink/tools/blinkpy/tool/commands/rebaseline.py
+++ b/third_party/blink/tools/blinkpy/tool/commands/rebaseline.py
@@ -308,13 +308,17 @@
                 debug_builders.add(builder)
 
         builders_to_fallback_paths = {}
+        wpt_builders = set()
         for builder in list(release_builders) + list(debug_builders):
-            port = self._tool.port_factory.get_from_builder_name(builder)
-            fallback_path = port.baseline_search_path()
-            if fallback_path not in builders_to_fallback_paths.values():
-                builders_to_fallback_paths[builder] = fallback_path
+            if not self._tool.builders.is_wpt_builder(builder):
+                port = self._tool.port_factory.get_from_builder_name(builder)
+                fallback_path = port.baseline_search_path()
+                if fallback_path not in builders_to_fallback_paths.values():
+                    builders_to_fallback_paths[builder] = fallback_path
+            else:
+                wpt_builders.add(builder)
 
-        return set(builders_to_fallback_paths)
+        return set(builders_to_fallback_paths) | wpt_builders
 
     def _rebaseline_commands(self, test_baseline_set, options):
         path_to_blink_tool = self._tool.path()
diff --git a/third_party/blink/tools/blinkpy/tool/commands/rebaseline_unittest.py b/third_party/blink/tools/blinkpy/tool/commands/rebaseline_unittest.py
index 41d6208..e4065a26 100644
--- a/third_party/blink/tools/blinkpy/tool/commands/rebaseline_unittest.py
+++ b/third_party/blink/tools/blinkpy/tool/commands/rebaseline_unittest.py
@@ -77,6 +77,14 @@
                 'port_name': 'test-win-win7',
                 'specifiers': ['Win7', 'Release']
             },
+            'MOCK wpt(1)': {
+                'port_name': 'test-linux-trusty',
+                'specifiers': ['Trusty', 'Release']
+            },
+            'MOCK wpt(2)': {
+                'port_name': 'test-linux-trusty',
+                'specifiers': ['Trusty', 'Release']
+            },
         })
         self.mac_port = self.tool.port_factory.get_from_builder_name(
             'MOCK Mac10.11')
@@ -198,6 +206,11 @@
         ])
         self.assertEqual(builders_to_fetch, {'MOCK Win7', 'MOCK Win10'})
 
+        builders_to_fetch = self.command._builders_to_fetch_from([
+            'MOCK Trusty', 'MOCK wpt(1)', 'MOCK wpt(2)'
+        ])
+        self.assertEqual(builders_to_fetch, {'MOCK Trusty', 'MOCK wpt(1)', 'MOCK wpt(2)'})
+
     def test_generic_baseline_paths(self):
         test_baseline_set = TestBaselineSet(self.tool)
         # Multiple ports shouldn't produce duplicate baseline paths.