#779 Allow to select only one compiler in a processor test class, but make the config-annotation deprecated to empasise that it's only to be used temporarily during debugging.

This commit is contained in:
Andreas Gudian 2016-03-13 20:49:59 +01:00
parent c595bd72e3
commit 9b2145c6a8
2 changed files with 54 additions and 1 deletions

View File

@ -60,7 +60,18 @@ public class AnnotationProcessorTestRunner extends ParentRunner<Runner> {
public AnnotationProcessorTestRunner(Class<?> klass) throws Exception { public AnnotationProcessorTestRunner(Class<?> klass) throws Exception {
super( klass ); super( klass );
runners = Arrays.<Runner> asList( runners = createRunners( klass );
}
@SuppressWarnings("deprecation")
private List<Runner> createRunners(Class<?> klass) throws Exception {
WithSingleCompiler singleCompiler = klass.getAnnotation( WithSingleCompiler.class );
if (singleCompiler != null) {
return Arrays.<Runner> asList( new InnerAnnotationProcessorRunner( klass, singleCompiler.value() ) );
}
return Arrays.<Runner> asList(
new InnerAnnotationProcessorRunner( klass, Compiler.JDK ), new InnerAnnotationProcessorRunner( klass, Compiler.JDK ),
new InnerAnnotationProcessorRunner( klass, Compiler.ECLIPSE ) ); new InnerAnnotationProcessorRunner( klass, Compiler.ECLIPSE ) );
} }

View File

@ -0,0 +1,42 @@
/**
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.testutil.runner;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Temporarily only use the specified compiler for the test during debugging / implementation.
* <p>
* Do not commit tests with this annotation present!
*
* @deprecated Do not commit tests with this annotation present. Tests are expected to work with all compilers.
* @author Andreas Gudian
*/
@Deprecated
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface WithSingleCompiler {
/**
* @return The compiler to use.
*/
Compiler value();
}