diff options
author | Piotr Gurgul <pgurgul@google.com> | 2009-09-01 21:58:52 -0700 |
---|---|---|
committer | Piotr Gurgul <pgurgul@google.com> | 2009-09-09 18:32:03 -0700 |
commit | b0b67269c3b92817f2794dbb2020c663b0509393 (patch) | |
tree | f3ff71e5699ece8db23b4f3474a2159f54e40629 /anttasks/src/com | |
parent | f5ceb7e53709083427bb3833e83039aa2cef4149 (diff) | |
download | sdk-b0b67269c3b92817f2794dbb2020c663b0509393.zip sdk-b0b67269c3b92817f2794dbb2020c663b0509393.tar.gz sdk-b0b67269c3b92817f2794dbb2020c663b0509393.tar.bz2 |
Add ant-based code coverage support to Android SDK
Target 'run-tests' launches all the unit tests against the tested project.
Target 'coverage' emma-instruments the tested project's classes,
runs the tests against instrumented classes, collects code coverage data
and extracts it to human-readable form as report.html.
android_test_rules.xml contain additional rules for test projects.
Test projects are auto-recognized by presence of the tested.project.dir
property, which will be auto-generated for tests projects. Temporarily,
please add this property manually to the build.properties file.
Current version is mainly tested with default, android generated test projects.
This version includes also fixing relative to absolute paths for
properties which are most likely to be changed by user in external
property file.
Diffstat (limited to 'anttasks/src/com')
-rw-r--r-- | anttasks/src/com/android/ant/SetupTask.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java index ffe8314..27d73d6 100644 --- a/anttasks/src/com/android/ant/SetupTask.java +++ b/anttasks/src/com/android/ant/SetupTask.java @@ -58,7 +58,8 @@ import javax.xml.xpath.XPathExpressionException; */ public final class SetupTask extends ImportTask { private final static String ANDROID_RULES = "android_rules.xml"; - + // additional android rules for test project - depends on android_rules.xml + private final static String ANDROID_TEST_RULES = "android_test_rules.xml"; // ant property with the path to the android.jar private final static String PROPERTY_ANDROID_JAR = "android.jar"; // LEGACY - compatibility with 1.6 and before @@ -103,6 +104,13 @@ public final class SetupTask extends ImportTask { // get the target property value String targetHashString = antProject.getProperty(ProjectProperties.PROPERTY_TARGET); + + boolean isTestProject = false; + + if (antProject.getProperty("tested.project.dir") != null) { + isTestProject = true; + } + if (targetHashString == null) { throw new BuildException("Android Target is not set."); } @@ -215,17 +223,21 @@ public final class SetupTask extends ImportTask { if (mDoImport) { // make sure the file exists. File templates = new File(templateFolder); + if (templates.isDirectory() == false) { throw new BuildException(String.format("Template directory '%s' is missing.", templateFolder)); } + String importedRulesFileName = isTestProject ? ANDROID_TEST_RULES : ANDROID_RULES; + // now check the rules file exists. - File rules = new File(templateFolder, ANDROID_RULES); + File rules = new File(templateFolder, importedRulesFileName); + if (rules.isFile() == false) { throw new BuildException(String.format("Build rules file '%s' is missing.", templateFolder)); - } + } // set the file location to import setFile(rules.getAbsolutePath()); |