[ssci] adding gclient testing support for the CIPD expand package cmd

Bug:b/279097790
Change-Id: I1edf1c33333bf4ddd32bf462f5d23733097c25d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4529697
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Dan Le Febvre <dlf@google.com>
diff --git a/gclient_scm.py b/gclient_scm.py
index 8acc425..e0a5a41 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -1596,6 +1596,20 @@
         if os.path.exists(cipd_cache_dir):
           raise
 
+  def expand_package_name(self, package_name_string, **kwargs):
+    """Run `cipd expand-package-name`.
+
+    CIPD package names can be declared with placeholder variables
+    such as '${platform}', this cmd will return the package name
+    with the variables resolved. The resolution is based on the host
+    the command is executing on.
+    """
+
+    kwargs.setdefault('stderr', subprocess2.PIPE)
+    cmd = ['cipd', 'expand-package-name', package_name_string]
+    ret = subprocess2.check_output(cmd, **kwargs).decode('utf-8')
+    return ret.strip()
+
   @contextlib.contextmanager
   def _create_ensure_file(self):
     try: