@@ -1033,39 +1033,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1033
1033
else (dirs, files)
1034
1034
}
1035
1035
1036
- /** Gets the name of the calling method via reflection.
1037
- *
1038
- * It does this in a way that needs to work both with the bootstrapped dotty
1039
- * and the non-bootstrapped version. Since the two compilers generate
1040
- * different bridges, we first need to filter out methods with the same name
1041
- * (bridges) - and then find the `@Test` method in our extending class
1042
- */
1043
- private def getCallingMethod (): String = {
1044
- val seen = mutable.Set .empty[String ]
1045
- Thread .currentThread.getStackTrace
1046
- .filter { elem =>
1047
- if (seen.contains(elem.getMethodName)) false
1048
- else { seen += elem.getMethodName; true }
1049
- }
1050
- .find { elem =>
1051
- val callingClass = Class .forName(elem.getClassName)
1052
- classOf [ParallelTesting ].isAssignableFrom(callingClass) &&
1053
- elem.getFileName != " ParallelTesting.scala"
1054
- }
1055
- .map(_.getMethodName)
1056
- .getOrElse {
1057
- throw new IllegalStateException (" Unable to reflectively find calling method" )
1058
- }
1059
- .takeWhile(_ != '$' )
1060
- }
1061
-
1062
1036
/** Compiles a single file from the string path `f` using the supplied flags */
1063
- def compileFile (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir): CompilationTest = {
1064
- val callingMethod = getCallingMethod()
1037
+ def compileFile (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir)(implicit testGroup : TestGroup ): CompilationTest = {
1065
1038
val sourceFile = new JFile (f)
1066
1039
val parent = sourceFile.getParentFile
1067
1040
val outDir =
1068
- outDirectory + callingMethod + " /" +
1041
+ outDirectory + testGroup.name + " /" +
1069
1042
sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + " /"
1070
1043
1071
1044
require(
@@ -1075,7 +1048,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1075
1048
)
1076
1049
1077
1050
val target = JointCompilationSource (
1078
- callingMethod ,
1051
+ testGroup.name ,
1079
1052
Array (sourceFile),
1080
1053
flags,
1081
1054
createOutputDirsForFile(sourceFile, parent, outDir)
@@ -1090,9 +1063,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1090
1063
* By default, files are compiled in alphabetical order. An optional seed
1091
1064
* can be used for randomization.
1092
1065
*/
1093
- def compileDir (f : String , flags : TestFlags , randomOrder : Option [Int ] = None , outDirectory : String = defaultOutputDir): CompilationTest = {
1094
- val callingMethod = getCallingMethod()
1095
- val outDir = outDirectory + callingMethod + " /"
1066
+ def compileDir (f : String , flags : TestFlags , randomOrder : Option [Int ] = None , outDirectory : String = defaultOutputDir)(implicit testGroup : TestGroup ): CompilationTest = {
1067
+ val outDir = outDirectory + testGroup.name + " /"
1096
1068
val sourceDir = new JFile (f)
1097
1069
checkRequirements(f, sourceDir, outDir)
1098
1070
@@ -1111,23 +1083,23 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1111
1083
val targetDir = new JFile (outDir + " /" + sourceDir.getName + " /" )
1112
1084
targetDir.mkdirs()
1113
1085
1114
- val target = JointCompilationSource (s " compiling ' $f' in test ' $callingMethod ' " , randomized, flags, targetDir)
1086
+ val target = JointCompilationSource (s " compiling ' $f' in test ' ${testGroup.name} ' " , randomized, flags, targetDir)
1115
1087
new CompilationTest (target)
1116
1088
}
1117
1089
1118
1090
/** Compiles all `files` together as a single compilation run. It is given a
1119
1091
* `testName` since files can be in separate directories and or be otherwise
1120
1092
* dissociated
1121
1093
*/
1122
- def compileList (testName : String , files : List [String ], flags : TestFlags , callingMethod : String = getCallingMethod(), outDirectory : String = defaultOutputDir ): CompilationTest = {
1123
- val outDir = outDirectory + callingMethod + " /" + testName + " /"
1094
+ def compileList (testName : String , files : List [String ], flags : TestFlags , outDirectory : String = defaultOutputDir)( implicit testGroup : TestGroup ): CompilationTest = {
1095
+ val outDir = outDirectory + testGroup.name + " /" + testName + " /"
1124
1096
1125
1097
// Directories in which to compile all containing files with `flags`:
1126
1098
val targetDir = new JFile (outDir)
1127
1099
targetDir.mkdirs()
1128
1100
assert(targetDir.exists, s " couldn't create target directory: $targetDir" )
1129
1101
1130
- val target = JointCompilationSource (s " $testName from $callingMethod " , files.map(new JFile (_)).toArray, flags, targetDir)
1102
+ val target = JointCompilationSource (s " $testName from ${testGroup.name} " , files.map(new JFile (_)).toArray, flags, targetDir)
1131
1103
1132
1104
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
1133
1105
new CompilationTest (target)
@@ -1150,17 +1122,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1150
1122
* - Directories can have an associated check-file, where the check file has
1151
1123
* the same name as the directory (with the file extension `.check`)
1152
1124
*/
1153
- def compileFilesInDir (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir): CompilationTest = {
1154
- val callingMethod = getCallingMethod()
1155
- val outDir = outDirectory + callingMethod + " /"
1125
+ def compileFilesInDir (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir)(implicit testGroup : TestGroup ): CompilationTest = {
1126
+ val outDir = outDirectory + testGroup.name + " /"
1156
1127
val sourceDir = new JFile (f)
1157
1128
checkRequirements(f, sourceDir, outDir)
1158
1129
1159
1130
val (dirs, files) = compilationTargets(sourceDir)
1160
1131
1161
1132
val targets =
1162
- files.map(f => JointCompilationSource (callingMethod , Array (f), flags, createOutputDirsForFile(f, sourceDir, outDir))) ++
1163
- dirs.map(dir => SeparateCompilationSource (callingMethod , dir, flags, createOutputDirsForDir(dir, sourceDir, outDir)))
1133
+ files.map(f => JointCompilationSource (testGroup.name , Array (f), flags, createOutputDirsForFile(f, sourceDir, outDir))) ++
1134
+ dirs.map(dir => SeparateCompilationSource (testGroup.name , dir, flags, createOutputDirsForDir(dir, sourceDir, outDir)))
1164
1135
1165
1136
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
1166
1137
new CompilationTest (targets)
@@ -1170,16 +1141,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1170
1141
* sub-directories and as such, does **not** perform separate compilation
1171
1142
* tests.
1172
1143
*/
1173
- def compileShallowFilesInDir (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir): CompilationTest = {
1174
- val callingMethod = getCallingMethod()
1175
- val outDir = outDirectory + callingMethod + " /"
1144
+ def compileShallowFilesInDir (f : String , flags : TestFlags , outDirectory : String = defaultOutputDir)(implicit testGroup : TestGroup ): CompilationTest = {
1145
+ val outDir = outDirectory + testGroup.name + " /"
1176
1146
val sourceDir = new JFile (f)
1177
1147
checkRequirements(f, sourceDir, outDir)
1178
1148
1179
1149
val (_, files) = compilationTargets(sourceDir)
1180
1150
1181
1151
val targets = files.map { file =>
1182
- JointCompilationSource (callingMethod , Array (file), flags, createOutputDirsForFile(file, sourceDir, outDir))
1152
+ JointCompilationSource (testGroup.name , Array (file), flags, createOutputDirsForFile(file, sourceDir, outDir))
1183
1153
}
1184
1154
1185
1155
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
0 commit comments