aboutsummaryrefslogtreecommitdiffstats
path: root/ant-glob-tests
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-05-10 16:58:03 -0700
committerXavier Ducrohet <xav@android.com>2012-05-16 18:19:56 -0700
commitc5578db599c6a1f36369f79411e7dafa030f9f56 (patch)
treebc2ccca5a919fd4226d7860248c08a462cdc9b92 /ant-glob-tests
parent71cc6480236e5a6650b7390dbd3fd3ecad3878f0 (diff)
downloadsdk-c5578db599c6a1f36369f79411e7dafa030f9f56.zip
sdk-c5578db599c6a1f36369f79411e7dafa030f9f56.tar.gz
sdk-c5578db599c6a1f36369f79411e7dafa030f9f56.tar.bz2
Replace current complex delta visitor by pattern based ones.
The build system relies on several different delta visitor that detect file changes to detect that needs to be rebuilt but the implementation of those files is based on going through folders recursively while keeping states. This is complex and prone to errors. The new mechanism is simply based on glob-pattern, relative to the project root. A set of predefined patterns stored in ChangedFileSet instance allow quick reuse. ChangeFileSetHelper stores those as well as allow creating others that are based on a project config (such as the output folder). This first CL replace the previous delta visitors in the PostCompilerBuilder. Replacing the ones in the PreCompilerBuilder will require a bit more work so I prefer splitting it in another CL. The code that runs the pattern recognition is coming from Ant and is stored in external/ant-glob. This is not all of Ant but a subset of the classes for our need. This CL does include a simple set of tests for the extracted Ant classes. Change-Id: I2ad1b116ffb29c9f4195d863d04f8812e87a31ca
Diffstat (limited to 'ant-glob-tests')
-rw-r--r--ant-glob-tests/.classpath8
-rw-r--r--ant-glob-tests/.gitignore6
-rw-r--r--ant-glob-tests/.project17
-rw-r--r--ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java37
4 files changed, 68 insertions, 0 deletions
diff --git a/ant-glob-tests/.classpath b/ant-glob-tests/.classpath
new file mode 100644
index 0000000..0a4978e
--- /dev/null
+++ b/ant-glob-tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ant-glob"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/ant-glob-tests/.gitignore b/ant-glob-tests/.gitignore
new file mode 100644
index 0000000..3826f65
--- /dev/null
+++ b/ant-glob-tests/.gitignore
@@ -0,0 +1,6 @@
+bin
+*~
+*.bak
+Thumbs.db
+*.class
+*.DS_Store
diff --git a/ant-glob-tests/.project b/ant-glob-tests/.project
new file mode 100644
index 0000000..4686cc9
--- /dev/null
+++ b/ant-glob-tests/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ant-glob-tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java b/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java
new file mode 100644
index 0000000..943ebd5
--- /dev/null
+++ b/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.tools.ant.types.selectors;
+
+import junit.framework.TestCase;
+
+
+public class SelectorUtilsTest extends TestCase {
+
+ public void test1() {
+ assertTrue(SelectorUtils.matchPath("**", "a"));
+
+ assertTrue(SelectorUtils.matchPath("a/**/b", "a/c/d/b"));
+ assertTrue(SelectorUtils.matchPath("a/**/b", "a/b"));
+ assertFalse(SelectorUtils.matchPath("a/**/b", "a/b/c"));
+
+ assertTrue(SelectorUtils.matchPath("a/**", "a"));
+ assertTrue(SelectorUtils.matchPath("a/**", "a/b"));
+
+ assertTrue(SelectorUtils.matchPath("bin/**/*.class", "bin/a/foo.class"));
+ assertFalse(SelectorUtils.matchPath("bin/**/*.class", "bin/a/fooclass"));
+ }
+}