-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standalone pan tests #125
Standalone pan tests #125
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<assembly> | ||
<id>with-tests</id> | ||
<formats> | ||
<format>jar</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<dependencySets> | ||
<dependencySet> | ||
<outputDirectory>/</outputDirectory> | ||
<useProjectArtifact>true</useProjectArtifact> | ||
<unpack>true</unpack> | ||
<scope>test</scope> | ||
</dependencySet> | ||
</dependencySets> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/test-classes</directory> | ||
<outputDirectory></outputDirectory> | ||
<includes> | ||
<include>**/*.class</include> | ||
</includes> | ||
<useDefaultExcludes>true</useDefaultExcludes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package org.quattor.pan; | ||
|
||
import org.quattor.pan.exceptions.SyntaxException; | ||
import java.util.*; | ||
|
||
/** | ||
* Created by iliclaey. | ||
* | ||
* When building the panc-project a panc-10.3-SNAPSHOT-fat-jar-with-tests.jar file is created. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
* This jar can be used to execute pan test files and should be used as follows: | ||
* `java -Dpanc.testdir="path" -Dpanc.tmpdir="path" -jar path/to/panc-10.3-SNAPSHOT-fat-jar-with-tests.jar`. | ||
* The panc.testdir and panc.tmpdir properties need to be set, otherwise an error will be thrown. | ||
* | ||
* To be able to execute your tests, they need to conform to a specific directory structure. | ||
* The directory you pass to the panc.testdir property needs to contain the _Functionality_, _Dependency_ or | ||
* _RootElement_ directories, depending on what type of tests you want to run. Each of these directories need to be | ||
* divided in subdirectories, which contain the test files (or more subdirectories). | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mention that this is structure and implementation also/already used as part the panc unittests, and where the |
||
* panc.testdir | ||
* |-- Dependency | ||
* |-- Functionality | ||
* | |-- subdir1 | ||
* | | |-- file1.pan | ||
* | | |-- file2.pan | ||
* | |-- subdir2 | ||
* | | |-- file1.pan | ||
* | | |-- file2.pan | ||
* |-- RootElement | ||
* | ||
* Dependency tests | ||
* ================ | ||
* A simple example: | ||
* | ||
* # dep: simple | ||
* object template simple; | ||
* | ||
* Functionality tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. describe this one before the |
||
* =================== | ||
* You can declare whether the expected result will be an exception or a value in the tree. | ||
* For example, if you expect a SyntaxException to be thrown, you would place the following line on top of the file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also add a short exampole for a value. |
||
* | ||
* # @expect=org.quattor.pan.exception.SyntaxException regex. | ||
* | ||
* The regex is optional and is used to check specific error messages. | ||
* If you expect a specific result, you should use an XPath. For example: | ||
* | ||
* # @expect="/profile/result=1" | ||
* | ||
* RootElement tests | ||
* ================= | ||
* Specific functionality tests to test the root element in the tree. | ||
* | ||
* | ||
* To run the tests in a specific directory, additional properties can be passed on to java: | ||
* - test_functionality: runs the tests in the _Functionality_ directory. Default value is true. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* - test_dependency: runs the tests in the _Dependency_ directory. Default value is false. | ||
* - test_rootelement: runs the tests in the _RootElement_ directory. Default value is false. | ||
* | ||
* For example, when you only want to run the tests in the _Dependency_ directory you would use the following command: | ||
* `java -Dpanc.testdir="path" -Dpanc.tmpdir="path" -Dtest_functionality="false" -Dtest_dependency="true" -jar ...`. | ||
* | ||
*/ | ||
public class PanTest { | ||
|
||
static Properties props; | ||
|
||
public static void main(String[] args) throws SyntaxException { | ||
|
||
props = System.getProperties(); | ||
runTests(); | ||
} | ||
|
||
public static void runTests() throws SyntaxException { | ||
|
||
JavaCompilerTest jct = new JavaCompilerTest(); | ||
|
||
String functionality = props.getProperty("test_functionality"); | ||
if (functionality != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why so complicated?
|
||
if (Boolean.parseBoolean(functionality)) { | ||
jct.javaFunctionalTests(); | ||
} | ||
} else { | ||
jct.javaFunctionalTests(); | ||
} | ||
|
||
String dependency = props.getProperty("test_dependency"); | ||
if (dependency != null) { | ||
if (Boolean.parseBoolean(dependency)) { | ||
jct.javaDependencyTests(); | ||
} | ||
} | ||
|
||
String rootElement = props.getProperty("test_rootelement"); | ||
if (rootElement != null) { | ||
if (Boolean.parseBoolean(rootElement)) { | ||
jct.javaRootElementTests(); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this assembly file is only relevant for this fat jar, bets rename it to
assembly-fat.xml
or so