You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AjcTestCaseTest.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM Corporation
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Adrian Colyer,
  11. * ******************************************************************/
  12. package org.aspectj.tools.ajc;
  13. import java.io.File;
  14. import org.aspectj.util.FileUtil;
  15. /**
  16. * @author colyer
  17. * Exercise the features of the AjcTestCase class and check they do as
  18. * expected
  19. */
  20. public class AjcTestCaseTest extends AjcTestCase {
  21. public void testCompile() {
  22. File baseDir = new File("../tests/base/test106");
  23. String[] args = new String[] {"Driver.java","pkg/Obj.java"};
  24. CompilationResult result = ajc(baseDir,args);
  25. assertNoMessages(result);
  26. RunResult rresult = run("Driver",new String[0],null);
  27. System.out.println(rresult.getStdOut());
  28. }
  29. public void testIncrementalCompile() throws Exception {
  30. File baseDir = new File("../tests/incrementalju/initialTests/classAdded");
  31. String[] args = new String[] {"-sourceroots","src","-d",".","-incremental"};
  32. CompilationResult result = ajc(baseDir,args);
  33. assertNoMessages(result);
  34. RunResult rr = run("main.Main",new String[0],null);
  35. // prepare for increment
  36. FileUtil.copyFile(new File(baseDir,"src.20/main/Main.java"),
  37. new File(ajc.getSandboxDirectory(),"src/main/Main.java"));
  38. assertFalse("main.Target does not exist",new File(ajc.getSandboxDirectory(),"main/Target.class").exists());
  39. result = ajc.doIncrementalCompile();
  40. assertNoMessages(result);
  41. assertTrue("main.Target created",new File(ajc.getSandboxDirectory(),"main/Target.class").exists());
  42. rr = run("main.Main",new String[0],null);
  43. System.out.println(rr.getStdOut());
  44. }
  45. }