Create ArtifactPath function to abstract test paths
When AOS is included as an external repo and renamed, paths have to be
updated. Make a function to handle all this.
Change-Id: If1dfbfb3191809d86da1dca92981b7a0b851c51f
diff --git a/aos/testing/BUILD b/aos/testing/BUILD
index d3287e3..1cff37e 100644
--- a/aos/testing/BUILD
+++ b/aos/testing/BUILD
@@ -117,3 +117,14 @@
"@com_google_googletest//:gtest",
],
)
+
+cc_library(
+ name = "path",
+ srcs = ["path.cc"],
+ hdrs = ["path.h"],
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+ deps = [
+ "@com_google_absl//absl/strings",
+ ],
+)
diff --git a/aos/testing/path.cc b/aos/testing/path.cc
new file mode 100644
index 0000000..f999e58
--- /dev/null
+++ b/aos/testing/path.cc
@@ -0,0 +1,16 @@
+#include "aos/testing/path.h"
+#include "absl/strings/str_cat.h"
+
+namespace aos {
+namespace testing {
+
+// Returns the path to the provided artifact which works when built both as an
+// external target and in the repo.
+std::string ArtifactPath(std::string_view path) {
+ // TODO(austin): Don't hard-code the repo name here since it likely will
+ // change.
+ return absl::StrCat("../org_frc971/", path);
+}
+
+} // namespace testing
+} // namespace aos
diff --git a/aos/testing/path.h b/aos/testing/path.h
new file mode 100644
index 0000000..1abad74
--- /dev/null
+++ b/aos/testing/path.h
@@ -0,0 +1,16 @@
+#ifndef AOS_TESTING_PATH_H_
+#define AOS_TESTING_PATH_H_
+
+#include <string>
+#include <string_view>
+
+namespace aos {
+namespace testing {
+
+// Returns the path to the provided artifact which works
+std::string ArtifactPath(std::string_view path);
+
+} // namespace testing
+} // namespace aos
+
+#endif // AOS_TESTING_PATH_H_