aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-12-21 15:36:24 -0800
committerTor Norbye <tnorbye@google.com>2012-12-21 16:39:57 -0800
commit9e871f23771fb63ef14d244ed355031ea4c960cd (patch)
treec4ccbc4d02f6ec809ec7fee0b0cac45c2dab9d01 /lint/cli
parent9a0002f9052def1f2eb4c9a7f4976f873043b72a (diff)
downloadsdk-9e871f23771fb63ef14d244ed355031ea4c960cd.zip
sdk-9e871f23771fb63ef14d244ed355031ea4c960cd.tar.gz
sdk-9e871f23771fb63ef14d244ed355031ea4c960cd.tar.bz2
Prevent circular dependencies in library project dependencies
Change-Id: Ia43c2436e01032ace7e2b13e59d60d10f71e7004
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java60
2 files changed, 77 insertions, 4 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java
index f57fb9c..4f427a2 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java
@@ -215,6 +215,10 @@ public abstract class AbstractCheckTest extends SdkTestCase {
return true;
}
+ if (issue == IssueRegistry.LINT_ERROR || issue == IssueRegistry.PARSER_ERROR) {
+ return !ignoreSystemErrors();
+ }
+
return false;
}
@@ -230,10 +234,14 @@ public abstract class AbstractCheckTest extends SdkTestCase {
return null;
}
+ protected boolean ignoreSystemErrors() {
+ return true;
+ }
+
public class TestLintClient extends Main {
private StringWriter mWriter = new StringWriter();
- TestLintClient() {
+ public TestLintClient() {
mReporters.add(new TextReporter(this, mWriter, false));
}
@@ -279,9 +287,14 @@ public abstract class AbstractCheckTest extends SdkTestCase {
}
@Override
- public void report(Context context, Issue issue, Severity severity, Location location,
- String message, Object data) {
- if (issue == IssueRegistry.LINT_ERROR) {
+ public void report(
+ @NonNull Context context,
+ @NonNull Issue issue,
+ @NonNull Severity severity,
+ @Nullable Location location,
+ @NonNull String message,
+ @Nullable Object data) {
+ if (ignoreSystemErrors() && (issue == IssueRegistry.LINT_ERROR)) {
return;
}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java
new file mode 100644
index 0000000..4f3c9ef
--- /dev/null
+++ b/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tools.lint.client.api;
+
+import com.android.tools.lint.checks.AbstractCheckTest;
+import com.android.tools.lint.checks.UnusedResourceDetector;
+import com.android.tools.lint.detector.api.Detector;
+
+import java.io.File;
+import java.util.Arrays;
+
+public class ProjectTest extends AbstractCheckTest {
+ @Override
+ protected boolean ignoreSystemErrors() {
+ return false;
+ }
+
+ public void testCycle() throws Exception {
+ // Ensure that a cycle in library project dependencies doesn't cause
+ // infinite directory traversal
+ File master = getProjectDir("MasterProject",
+ // Master project
+ "multiproject/main-manifest.xml=>AndroidManifest.xml",
+ "multiproject/main.properties=>project.properties",
+ "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
+ );
+ File library = getProjectDir("LibraryProject",
+ // Library project
+ "multiproject/library-manifest.xml=>AndroidManifest.xml",
+ "multiproject/main.properties=>project.properties", // RECURSIVE - points to self
+ "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
+ "multiproject/strings.xml=>res/values/strings.xml"
+ );
+
+ assertEquals(""
+ + "MasterProject/project.properties: Error: Circular library dependencies; check your project.properties files carefully [LintError]\n"
+ + "1 errors, 0 warnings\n",
+
+ checkLint(Arrays.asList(master, library)));
+ }
+
+ @Override
+ protected Detector getDetector() {
+ return new UnusedResourceDetector();
+ }
+}