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.

AjcTest.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* *******************************************************************
  2. * Copyright (c) 2004,2019 IBM Corporation, contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. * ******************************************************************/
  9. package org.aspectj.testing;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. import org.aspectj.tools.ajc.AjcTestCase;
  13. import org.aspectj.util.LangUtil;
  14. /**
  15. * @author Adrian Colyer
  16. * @author Andy Clement
  17. */
  18. public class AjcTest {
  19. // private static boolean is13VMOrGreater = true;
  20. private static boolean is1dot4VMOrGreater = true;
  21. private static boolean is15VMOrGreater = false;
  22. private static boolean is16VMOrGreater = false;
  23. private static boolean is17VMOrGreater = false;
  24. private static boolean is18VMOrGreater = false;
  25. private static boolean is19VMOrGreater = false;
  26. private static boolean is10VMOrGreater = false;
  27. private static boolean is11VMOrGreater = false;
  28. private static boolean is12VMOrGreater = false;
  29. private static boolean is13VMOrGreater = false;
  30. private static boolean is14VMOrGreater = false;
  31. static { // matching logic is also in org.aspectj.util.LangUtil
  32. is1dot4VMOrGreater = true;
  33. is15VMOrGreater = true;
  34. is16VMOrGreater = true;
  35. is17VMOrGreater = true;
  36. is18VMOrGreater = true;
  37. is19VMOrGreater = LangUtil.is9VMOrGreater();
  38. is10VMOrGreater = LangUtil.is10VMOrGreater();
  39. is11VMOrGreater = LangUtil.is11VMOrGreater();
  40. is12VMOrGreater = LangUtil.is12VMOrGreater();
  41. is13VMOrGreater = LangUtil.is13VMOrGreater();
  42. is14VMOrGreater = LangUtil.is14VMOrGreater();
  43. }
  44. private List<ITestStep> testSteps = new ArrayList<>();
  45. private String dir;
  46. private String pr;
  47. private String title;
  48. private String keywords;
  49. private String comment;
  50. private String vmLevel = "1.3";
  51. public AjcTest() {
  52. }
  53. public void addTestStep(ITestStep step) {
  54. testSteps.add(step);
  55. step.setTest(this);
  56. }
  57. public boolean runTest(AjcTestCase testCase) {
  58. if (!canRunOnThisVM()) return false;
  59. try {
  60. System.out.print("TEST: " + getTitle() + "\t");
  61. for (ITestStep step: testSteps) {
  62. step.setBaseDir(getDir());
  63. System.out.print(".");
  64. step.execute(testCase);
  65. }
  66. } finally {
  67. System.out.println("DONE");
  68. }
  69. return true;
  70. }
  71. public boolean canRunOnThisVM() {
  72. if (vmLevel.equals("1.3")) return true;
  73. boolean canRun = true;
  74. if (vmLevel.equals("1.4")) canRun = is1dot4VMOrGreater;
  75. if (vmLevel.equals("1.5")) canRun = is15VMOrGreater;
  76. if (vmLevel.equals("1.6")) canRun = is16VMOrGreater;
  77. if (vmLevel.equals("1.7")) canRun = is17VMOrGreater;
  78. if (vmLevel.equals("1.8")) canRun = is18VMOrGreater;
  79. if (vmLevel.equals("1.9")) canRun = is19VMOrGreater;
  80. if (vmLevel.equals("10")) canRun = is10VMOrGreater;
  81. if (vmLevel.equals("11")) canRun = is11VMOrGreater;
  82. if (vmLevel.equals("12")) canRun = is12VMOrGreater;
  83. if (vmLevel.equals("13")) canRun = is13VMOrGreater;
  84. if (vmLevel.equals("14")) canRun = is14VMOrGreater;
  85. if (!canRun) {
  86. System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
  87. + ", currently running on " + System.getProperty("java.vm.version"));
  88. }
  89. return canRun;
  90. }
  91. /**
  92. * @return Returns the comment.
  93. */
  94. public String getComment() {
  95. return comment;
  96. }
  97. /**
  98. * @param comment The comment to set.
  99. */
  100. public void setComment(String comment) {
  101. this.comment = comment;
  102. }
  103. /**
  104. * @return Returns the dir.
  105. */
  106. public String getDir() {
  107. return dir;
  108. }
  109. /**
  110. * @param dir The dir to set.
  111. */
  112. public void setDir(String dir) {
  113. dir = "../tests/" + dir;
  114. this.dir = dir;
  115. }
  116. /**
  117. * @return Returns the keywords.
  118. */
  119. public String getKeywords() {
  120. return keywords;
  121. }
  122. /**
  123. * @param keywords The keywords to set.
  124. */
  125. public void setKeywords(String keywords) {
  126. this.keywords = keywords;
  127. }
  128. /**
  129. * @return Returns the pr.
  130. */
  131. public String getPr() {
  132. return pr;
  133. }
  134. /**
  135. * @param pr The pr to set.
  136. */
  137. public void setPr(String pr) {
  138. this.pr = pr;
  139. }
  140. /**
  141. * @return Returns the title.
  142. */
  143. public String getTitle() {
  144. return title;
  145. }
  146. /**
  147. * @param title The title to set.
  148. */
  149. public void setTitle(String title) {
  150. this.title = title;
  151. }
  152. /**
  153. * @param vmLevel The vmLevel to set.
  154. */
  155. public void setVm(String vmLevel) {
  156. this.vmLevel = vmLevel;
  157. }
  158. /**
  159. * @return Returns the vmLevel.
  160. */
  161. public String getVmLevel() {
  162. return vmLevel;
  163. }
  164. }