[recipes] Check for empty results_dir string when constructing path

When processing a skipped shard, an empty string is passed
as the results_dir. Using config_types.Path.join() resulted in no errors, but it has been deprecated. The preferred function, config_types.Path.joinpath(), doesn't work on an empty string, so now we validate that results_dir isn't an empty string.

Change-Id: I6c4e92200b2432c4d77009a98b3b88bdc7bce2e4
Reviewed-on: https://fuchsia-review.googlesource.com/c/infra/recipes/+/1040563
Commit-Queue: Danielle Kay <danikay@google.com>
Reviewed-by: Oliver Newman <olivernewman@google.com>
diff --git a/recipe_modules/testing/api.py b/recipe_modules/testing/api.py
index 586430f..0651eca 100644
--- a/recipe_modules/testing/api.py
+++ b/recipe_modules/testing/api.py
@@ -310,16 +310,17 @@
                         resultdb_base_variant,
                         resultdb_tags,
                     )
-            snapshot_zip = self.results_dir.join(
-                self._api.testing_requests.SNAPSHOT_NAME
-            )
-            self._api.path.mock_add_paths(snapshot_zip)
-            if self._api.path.exists(snapshot_zip):
-                self._api.file.move(
-                    "move snapshot to output dir",
-                    snapshot_zip,
-                    upload_dir / self._api.testing_requests.SNAPSHOT_NAME,
+            if self.results_dir:
+                snapshot_zip = self.results_dir.joinpath(
+                    self._api.testing_requests.SNAPSHOT_NAME
                 )
+                self._api.path.mock_add_paths(snapshot_zip)
+                if self._api.path.exists(snapshot_zip):
+                    self._api.file.move(
+                        "move snapshot to output dir",
+                        snapshot_zip,
+                        upload_dir / self._api.testing_requests.SNAPSHOT_NAME,
+                    )
 
             # If an output was important enough to present (meaning it's in _outputs),
             # we should upload it so it can be shown in Sponge, etc.
diff --git a/recipe_modules/testing/tests/full.expected/test_with_skipped_shards.json b/recipe_modules/testing/tests/full.expected/test_with_skipped_shards.json
index 4c33010..6baa4b5 100644
--- a/recipe_modules/testing/tests/full.expected/test_with_skipped_shards.json
+++ b/recipe_modules/testing/tests/full.expected/test_with_skipped_shards.json
@@ -3379,35 +3379,6 @@
     ]
   },
   {
-    "cmd": [
-      "vpython3",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "move",
-      "snapshot.zip",
-      "[CLEANUP]/fuchsia-skipped-0001_tmp_1/snapshot.zip"
-    ],
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "fuchsia:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "upload fuchsia-skipped-0001 test results.move snapshot to output dir",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
     "cmd": [],
     "name": "upload fuchsia-skipped-0001 test results.move test outputs",
     "~followup_annotations": [
@@ -3521,35 +3492,6 @@
     ]
   },
   {
-    "cmd": [
-      "vpython3",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "move",
-      "snapshot.zip",
-      "[CLEANUP]/fuchsia-skipped-0002_tmp_1/snapshot.zip"
-    ],
-    "infra_step": true,
-    "luci_context": {
-      "realm": {
-        "name": "fuchsia:ci"
-      },
-      "resultdb": {
-        "current_invocation": {
-          "name": "invocations/build:8945511751514863184",
-          "update_token": "token"
-        },
-        "hostname": "rdbhost"
-      }
-    },
-    "name": "upload fuchsia-skipped-0002 test results.move snapshot to output dir",
-    "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
-    ]
-  },
-  {
     "cmd": [],
     "name": "upload fuchsia-skipped-0002 test results.move test outputs",
     "~followup_annotations": [