2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.util
.ArrayList
;
23 public class ShowTargets
25 public static void main( String
[] args
)
27 ArrayList
<String
> targets
= new ArrayList
<String
>();
28 ArrayList
<String
> descs
= new ArrayList
<String
>();
31 descs
.add( "runs all complex tests in this module" );
33 int maxTargetLength
= 3;
35 for ( int i
= 0; i
< args
.length
; ++i
)
37 String completePotentialClassName
= args
[i
].replace( '/', '.' );
40 if ( completePotentialClassName
.endsWith( ".TestCase" ) )
42 if ( completePotentialClassName
.endsWith( ".TestSkeleton" ) )
46 Class
<?
> potentialTestClass
= null;
47 try { potentialTestClass
= Class
.forName( completePotentialClassName
); }
48 catch( java
.lang
.ClassNotFoundException e
)
53 // see if it is derived from complexlib.ComplexTestCase
54 Class
<?
> superClass
= potentialTestClass
.getSuperclass();
55 while ( superClass
!= null )
57 if ( superClass
.getName().equals( "complexlib.ComplexTestCase" ) )
59 String bareClassName
= completePotentialClassName
.substring( completePotentialClassName
.lastIndexOf( '.' ) + 1 );
60 String target
= "run_" + bareClassName
;
61 targets
.add( target
);
62 descs
.add( getShortTestDescription( potentialTestClass
) );
64 if ( maxTargetLength
< target
.length() )
65 maxTargetLength
= target
.length();
68 superClass
= superClass
.getSuperclass();
72 System
.out
.println( "possible targets:" );
73 for ( int i
=0; i
<targets
.size(); ++i
)
76 String target
= targets
.get(i
);
78 System
.out
.print( " " + target
);
79 for ( int s
= maxTargetLength
- target
.length(); s
>0; --s
)
80 System
.out
.print( " " );
82 System
.out
.println( " (" + descs
.get(i
) + ")" );
86 private static String
getShortTestDescription( Class
<?
> _testClass
)
88 java
.lang
.reflect
.Method getShortDescriptionMethod
= null;
89 try { getShortDescriptionMethod
= _testClass
.getMethod( "getShortTestDescription", new Class
[]{} ); }
90 catch( Exception e
) { }
92 if ( getShortDescriptionMethod
!= null )
96 return (String
)getShortDescriptionMethod
.invoke( null, new Object
[]{} );
98 catch( Exception e
) { }
100 return "no description provided by the test";