Lint check tests: fix windows path separators.
The output from the lint check typically contains
a few directory/filenames.
On Windows we need to change the separators to the
unix-style forward slash to make the test as
OS-agnostic as possible.
Change-Id: I6f223fda8c294eaee2f4e522df1cc10a6145ef22
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
index b0870f0..6a6c1cc 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java
@@ -110,7 +110,11 @@
return mOutput.toString();
}
- /** Run lint on the given files when constructed as a separate project */
+ /**
+ * Run lint on the given files when constructed as a separate project
+ * @return The output of the lint check. On Windows, this transforms all directory
+ * separators to the unix-style forward slash.
+ */
protected String lintProject(String... relativePaths) throws Exception {
assertFalse("getTargetDir must be overridden to make a unique directory",
getTargetDir().equals(getTempDir()));
@@ -126,7 +130,14 @@
addManifestFile(projectDir);
- return checkLint(Collections.singletonList(projectDir));
+ String result = checkLint(Collections.singletonList(projectDir));
+ // The output typically contains a few directory/filenames.
+ // On Windows we need to change the separators to the unix-style
+ // forward slash to make the test as OS-agnostic as possible.
+ if (File.separatorChar != '/') {
+ result = result.replace(File.separatorChar, '/');
+ }
+ return result;
}
private void addManifestFile(File projectDir) throws IOException {