From d98b9d8aea8cb7339f961bbd3fe0659f1a138a85 Mon Sep 17 00:00:00 2001 From: wisberg Date: Sat, 29 Jan 2005 12:56:14 +0000 Subject: [PATCH] build tests (skipped), enabled license tests again... --- build/testsrc/BuildModuleTests.java | 13 +- .../internal/build/BuildModuleTest.java | 22 ++-- .../aspectj/internal/build/ModulesTest.java | 122 +++++++++++++++++- 3 files changed, 138 insertions(+), 19 deletions(-) diff --git a/build/testsrc/BuildModuleTests.java b/build/testsrc/BuildModuleTests.java index 8a03cc65e..00dec3d09 100644 --- a/build/testsrc/BuildModuleTests.java +++ b/build/testsrc/BuildModuleTests.java @@ -32,9 +32,6 @@ public class BuildModuleTests extends TestCase { private static final String BASE_DIR = "../"; private static final String[] JDT_SOURCE_DIRS = new String[] {}; - // sources moved to shadow/ directory -// {"antadapter", "batch", "codeassist", "compiler", -// "dom", "eval", "formatter", "model", "search" }; public static Test suite() { TestSuite suite = new TestSuite("Build module tests"); @@ -46,10 +43,7 @@ public class BuildModuleTests extends TestCase { /** @return String tag of license if not default */ public static String getLicense(String module) { - if ("org.eclipse.jdt.core".equals(module)) { - return Checklics.CPL_IBM_PARC_TAG; - } - return null; + return null; // use permissive default } public BuildModuleTests(String name) { super(name); } @@ -73,6 +67,9 @@ public class BuildModuleTests extends TestCase { public void testLicense_org_aspectj_ajdt_core() { checkLicense("org.aspectj.ajdt.core"); } + public void testLicense_org_aspectj_lib() { + checkLicense("org.aspectj.lib"); + } public void testLicense_org_eclipse_jdt_core() { final String mod = "org.eclipse.jdt.core"; final String pre = BASE_DIR + mod + "/"; @@ -129,7 +126,7 @@ public class BuildModuleTests extends TestCase { // assertTrue(!replaceFailed); // license = Checklics.CPL_IBM_PARC_XEROX_TAG; // } - int fails = Checklics.runDirect(moduleDir.getPath(), license); + int fails = Checklics.runDirect(moduleDir.getPath(), license, true); if (0 != fails) { if (replacing) { BuildModuleTests.replaceFailed = true; diff --git a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java index df5861a0d..2cbe7e7ca 100644 --- a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java +++ b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java @@ -1,6 +1,7 @@ /* ******************************************************************* * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). + * 2002 Palo Alto Research Center, Incorporated (PARC), + * 2005 Contributors. * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Common Public License v1.0 @@ -43,6 +44,7 @@ import junit.framework.TestCase; */ public class BuildModuleTest extends TestCase { + private static boolean printedMessage; private static final String SKIP_MESSAGE = "Define \"run.build.tests\" as a system property to run tests to build "; private static final String BUILD_CONFIG; @@ -121,8 +123,7 @@ public class BuildModuleTest extends TestCase { } public void testAspectjtools() { - if (!building) { - System.err.println(SKIP_MESSAGE + "aspectjtools"); + if (!shouldBuild("aspectjtools")) { return; } File baseDir = new File(".."); @@ -163,8 +164,7 @@ public class BuildModuleTest extends TestCase { } void checkBuildProduct(File productDir, File baseDir, File distDir, File jarDir) { - if (!building) { - System.err.println(SKIP_MESSAGE + "product " + productDir); + if (!shouldBuild(productDir.getPath())) { return; } assertTrue(null != productDir); @@ -233,13 +233,19 @@ public class BuildModuleTest extends TestCase { String[] args) { checkBuild(module, classname, args, false); } - + + boolean shouldBuild(String target) { + if (!building && !printedMessage) { + System.err.println(SKIP_MESSAGE + target + " (this is the only warning)"); + printedMessage = true; + } + return building; + } void checkBuild(String module, String classname, String[] args, boolean addAnt) { - if (!building) { - System.err.println(SKIP_MESSAGE + "module " + module); + if (!shouldBuild(module)) { return; } assertTrue(null != module); diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java index 2522f256b..fee0d5cf6 100644 --- a/build/testsrc/org/aspectj/internal/build/ModulesTest.java +++ b/build/testsrc/org/aspectj/internal/build/ModulesTest.java @@ -1,6 +1,7 @@ /* ******************************************************************* * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). + * 2002 Palo Alto Research Center, Incorporated (PARC), + * 2005 Contributors. * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Common Public License v1.0 @@ -9,6 +10,7 @@ * * Contributors: * Xerox/PARC initial implementation + * Wes Isberg build tests * ******************************************************************/ package org.aspectj.internal.build; @@ -19,9 +21,13 @@ import java.util.Iterator; import junit.framework.TestCase; +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; import org.aspectj.internal.tools.ant.taskdefs.AntBuilder; +import org.aspectj.internal.tools.ant.taskdefs.BuildModule; import org.aspectj.internal.tools.build.Messager; import org.aspectj.internal.tools.build.Module; import org.aspectj.internal.tools.build.Modules; @@ -85,8 +91,10 @@ public class ModulesTest extends TestCase { public void testAllModulesCreation() { File baseDir = new File(".."); - File[] files = baseDir.listFiles(); + String[] knowns = {"runtime", "util", "weaver" }; + File[] files = new File[knowns.length]; for (int i = 0; i < files.length; i++) { + files[i] = new File(knowns[i]); if (files[i].isDirectory()) { File classpath = new File(files[i], ".classpath"); if (classpath.exists()) { @@ -124,6 +132,114 @@ public class ModulesTest extends TestCase { assertTrue(classpath.toString(), false); } } - + + + /********************************************************************* + * The following tests/code enable you to run the entire build in JUnit + * to debug directly from Eclipse. To compile using Javac, you will + * need to add tools.jar to the run classpath. + */ + public void skip_testBuildingAspectJModule() { + final String moduleName = "org.aspectj.lib"; + + File modulesDir = new File("..").getAbsoluteFile(); + File buildDir = new File(modulesDir, "aj-build"); + File distDir = new File(buildDir, "dist"); + File jarDir = new File(buildDir, "jars"); + File moduleDir = new File(modulesDir, moduleName); + File jar = new File(jarDir, "org.aspectj.lib.jar"); + jarDir.mkdirs(); + distDir.mkdirs(); + if (jar.canRead()) { + assertTrue(jar.delete()); + } + Project project = new Project(); + project.setBaseDir(modulesDir); + project.setName("testAspectjbuild"); + + BuildModule bm = new BuildModule(); + bm.setProject(project); + bm.setAssembleall(true); + bm.setBuildConfig(""); + bm.setModule(moduleName); + bm.setBasedir(new Path(project, modulesDir.getPath())); + bm.setDistdir(new Path(project, buildDir.getPath())); + bm.setJardir(new Path(project, jarDir.getPath())); + bm.setModuledir(new Path(project, moduleDir.getPath())); + bm.setTrimtesting(true); + bm.setBuildConfig(""); + bm.setVersion("1.2"); + bm.setVerbose(true); + bm.setFailonerror(true); + + bm.execute(); + + assertTrue(jar.canRead()); + } + + public void skip_testBuildingProduct() { + final String productName = "tools"; + File modulesDir = new File("..").getAbsoluteFile(); + File buildDir = new File(modulesDir, "aj-build"); + File distDir = new File(buildDir, "dist"); + File jarDir = new File(buildDir, "jars"); + File productDir = new File(modulesDir, "build/products/" + productName); + + jarDir.mkdirs(); + distDir.mkdirs(); + + Project project = new Project(); + project.setBaseDir(modulesDir); + project.setName("testAspectjToolsbuild"); + project.addBuildListener(new EventBuildListener(Project.MSG_WARN)); + + BuildModule bm = new BuildModule(); + bm.setProject(project); + bm.setAssembleall(true); + bm.setBuildConfig(""); + bm.setProductdir(new Path(project, productDir.getPath())); + bm.setBasedir(new Path(project, modulesDir.getPath())); + bm.setDistdir(new Path(project, distDir.getPath())); + bm.setJardir(new Path(project, jarDir.getPath())); + bm.setTrimtesting(true); + bm.setBuildConfig(""); + bm.setVersion("1.2"); + bm.setFailonerror(true); + bm.execute(); + + File libDir = new File(distDir, "tools/lib"); + String[] jars = { "tools", "rt", "weaver", "lib"}; + for (int i = 0; i < jars.length; i++) { + File jar = new File(libDir, "aspectj" + jars[i] + ".jar"); + assertTrue(jar.getPath(), jar.canRead()); + if (10 > jar.length()) { + assertTrue(jar + " too small", false); + } + } + } + /** + * Show messages from the task. + * (normally shown by Ant's default listener) + */ + static class EventBuildListener implements BuildListener { + final int min; + EventBuildListener(int min) { + this.min = min; + } + public void buildFinished(BuildEvent event) {} + public void buildStarted(BuildEvent event) { } + public void messageLogged(BuildEvent event) { + if (min <= event.getPriority()) { + Task t = event.getTask(); + String src = (null == t ? "project" : t.getTaskName()); + System.out.println(src + ": " + event.getMessage()); + } + } + public void targetFinished(BuildEvent event) { } + public void targetStarted(BuildEvent event) { } + public void taskFinished(BuildEvent event) { } + public void taskStarted(BuildEvent event) { } + + } } -- 2.39.5