src/JavaTestsLoader.st
author vranyj1
Wed, 23 Nov 2011 15:26:06 +0000
branchjk_new_structure
changeset 1152 040cba55a7d2
parent 1075 927aeb3649fc
child 1155 d6f6d5fc0343
permissions -rw-r--r--
Copyright fixes

"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modification done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 Parts of the code written by Claus Gittinger are under following
 license:

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contain a signature
     of one of the above copright owners. For exact set of such code
     see the differences between this version and version stx:lib
     as of 1.9.2010
"
"{ Package: 'stx:libjava' }"

Object subclass:#JavaTestsLoader
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Tests'
!

!JavaTestsLoader class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modification done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 Parts of the code written by Claus Gittinger are under following
 license:

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contain a signature
     of one of the above copright owners. For exact set of such code
     see the differences between this version and version stx:lib
     as of 1.9.2010

"
! !

!JavaTestsLoader class methodsFor:'accessing'!

buildSuiteForLibjava

    ^self buildSuiteFrom: 
        (self loadLibjava)

    "
        JavaTestsLoader buildSuiteForLibjava
    "

    "Created: / 21-06-2011 / 17:39:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

buildSuiteForMauve

    ^self buildSuiteFrom: 
        (self loadMauve)

    "
        JavaTestsLoader buildSuiteForMauve
    "

    "Created: / 21-06-2011 / 17:40:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

buildSuiteForMauveToFix

    ^self buildSuiteFrom: 
        (self loadMauveToFix)

    "
        JavaTestsLoader buildSuiteForMauveToFix
    "

    "Created: / 21-06-2011 / 17:40:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTestsLoader class methodsFor:'loading'!

load
    JavaTestsResource build.
    self loadIn:JavaTestsResource classpath

    "Created: / 07-05-2011 / 18:43:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

load:testdir 
    |base dirs|

    base := (UserPreferences current javaTestsDirectory asFilename / testdir) 
                pathName.
    dirs := JavaTestsResource classpath 
                select:[:each | each startsWith:base ].
    self loadIn:dirs.

    "
        JavaTestsLoader load: 'libjava'"
    "Created: / 07-05-2011 / 18:40:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTestsLoader class methodsFor:'loading - test suites'!

loadLibjava
    | cp |
    JavaTestsResource new setUp.
    cp := JavaTestsResource classpathForLibjava.
    ^ self loadIn: cp

    "Created: / 21-06-2011 / 17:35:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (format): / 03-11-2011 / 10:17:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!

loadMauve
    |cp|

    JavaTestsResource new setUp.
    cp := JavaTestsResource classpathForMauve.
    ^self loadIn: cp

    "Created: / 11-06-2011 / 16:03:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

loadMauve: pattern
    |cp|

    JavaTestsResource new setUp.
    cp := JavaTestsResource classpathForMauve.
    ^self loadIn: cp matching: pattern.

    "
        JavaTestsLoader loadMauve:'gnu.testlet.java.lang.String.*'
    "

    "Created: / 12-06-2011 / 21:56:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 20-06-2011 / 19:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

loadMauveToFix
    |cp|

    JavaTestsResource new setUp.
    cp := JavaTestsResource classpathForMauve.
    self 
        loadIn: cp matching:'gnu.testlet.java.lang.*';
        loadIn: cp matching:'gnu.testlet.java.lang.reflect.*';
        loadIn: cp matching:'gnu.testlet.java.util.*';
        loadIn: cp matching:'gnu.testlet.java.io.*';
        loadIn: cp matching:'gnu.testlet.java.nio.*'.

    "
        JavaTestsLoader loadMauveToFix    
    "

    "Created: / 11-06-2011 / 16:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTestsLoader class methodsFor:'private'!

buildSuiteFrom: classes

    | javaTestCases suite |

    javaTestCases := OrderedCollection new.
    suite := TestSuite new.

    classes do:
        [:jclass|
        (jclass ~~ (Java at:'stx.libjava.tests.JUnit3Tests')
            and:[jclass ~~ (Java at:'stx.libjava.tests.JUnit4Tests')
                and:[jclass isTestCaseLike]])
                    ifTrue:
                        [ | tc |
                        tc := jclass asTestCase.
                                                (tc askFor:#isTestlet) ifTrue:[
                                                        tc shouldFork: true.
                                                ].
                        tc isAbstract ifFalse:[javaTestCases add:tc ]]].

    javaTestCases do:
                [:each | 
                suite addTests:each buildSuite tests ].

    ^suite

    "Modified: / 21-06-2011 / 17:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

loadIn: directories

    ^self loadIn: directories matching: '*'

    "Created: / 11-06-2011 / 16:05:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

loadIn: directories matching: pattern 
    | classes |

    JavaInitializedResource new setUp.
    JavaLibrariesResource new setUp.
    JavaTestsResource new setUp.
    classes := OrderedCollection new.
    directories do: [
        :each | 
        each asFilename exists ifTrue: [
            classes addAll: (JavaVM loadClassesIn: each matching: pattern)
        ]
    ].
    ^ classes

    "Created: / 11-06-2011 / 16:05:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 20-06-2011 / 19:02:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaTestsLoader class methodsFor:'documentation'!

version_SVN
    ^ '$Id$'
! !