Skip to content

Commit

Permalink
Merge pull request #42 from RosesTheN00b/dev
Browse files Browse the repository at this point in the history
Added ZUTZCPC task
  • Loading branch information
RosesTheN00b committed Jul 7, 2018
2 parents a36ebb4 + 2f73b49 commit 7f6cfc9
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -58,12 +58,12 @@ Or hardcode specific versions in your build.gradle (not preferred):

buildscript {
dependencies {
classpath group: 'de.sebastianruziczka', name: 'gradle-cobol-plugin-unittest-extension', version: '0.0.28'
classpath group: 'de.sebastianruziczka', name: 'gradle-cobol-plugin-unittest-extension', version: '0.0.29'
}
}

plugins {
id 'de.sebastianruziczka.Cobol' version '0.0.37'
id 'de.sebastianruziczka.Cobol' version '0.0.38'
}

settings.gradle:
Expand Down
2 changes: 1 addition & 1 deletion README.md.base
Expand Up @@ -63,7 +63,7 @@ Or hardcode specific versions in your build.gradle (not preferred):
}

plugins {
id 'de.sebastianruziczka.Cobol' version '0.0.37'
id 'de.sebastianruziczka.Cobol' version '0.0.38'
}

settings.gradle:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -28,7 +28,7 @@ dependencies {

def applicationName = "CobolPluginUnitTestExtension"
group = 'de.sebastianruziczka'
version = '0.0.28'
version = '0.0.29'
def realVersion = ''
if (project.hasProperty("generateLatest")) {
realVersion = ' (' + version + ')'
Expand Down
30 changes: 23 additions & 7 deletions src/main/groovy/de/sebastianruziczka/cobolunit/CobolUnit.groovy
Expand Up @@ -40,8 +40,24 @@ class CobolUnit implements CobolTestFramework{
this.configuration = configuration
this.project = project

this.project.task('computeTestCoverage', type:ComputeTestCoverageTask){
ZUTZCPC zutzcpcInstance = new ZUTZCPC(this.frameworkBase(), this.configuration)
this.zutzcpc = zutzcpcInstance


/**
* Maybe the precompiler task is already defined (by the integrationtest->configure)
*/
if(! project.tasks.findByName('compileZUTZCPC')){
this.project.task('compileZUTZCPC', type:CompileZUTZCPC){
project = project
group = 'COBOL UNIT'
description = 'Compiles the cobol unittest precompiler (ZUTZCPC)'
zutzcpc = zutzcpcInstance
}
}
this.project.tasks.testUnit.dependsOn << this.project.tasks.compileZUTZCPC

this.project.task('computeTestCoverage', type:ComputeTestCoverageTask){
group: 'COBOL Development'
description: 'Generates a testcoverage xml (cobertura-style)'

Expand All @@ -54,10 +70,6 @@ class CobolUnit implements CobolTestFramework{

@Override
int prepare() {
logger.info('Setup ZUTZCPC test framework')
this.zutzcpc = new ZUTZCPC(this.frameworkBin(), this.configuration)
this.zutzcpc.setup()

logger.info('Create default test.conf')
this.createTestConf()
return 0
Expand All @@ -75,7 +87,7 @@ class CobolUnit implements CobolTestFramework{
}

private String defaultConfPath() {
return this.frameworkBin() + '/' + DEFAULT_CONF_NAME
return this.frameworkBin() + DEFAULT_CONF_NAME
}

@Override
Expand Down Expand Up @@ -103,7 +115,7 @@ class CobolUnit implements CobolTestFramework{
logger.info('Preprocess Test: ' + testName)
this.zutzcpc.preprocessTest(unitSourceFile, this.defaultConfPath(), CobolCodeType.unit_test)

if(this.configuration.unittestCodeCoverage) {
if(coverage == TestCoverageIs.Enabled) {
unitSourceFile.modifyTestModulePath(this.frameworkBin() + '/' + new FixedFileConverter(this.configuration).fromOriginalToFixed(file.getRelativePath(unit_test)))
file.setMeta(ABSOLUTE_FIXED_UNITTEST_PATH, this.configuration.projectFileResolver(unitSourceFile.actualTestfilePath()).absolutePath)

Expand Down Expand Up @@ -132,6 +144,10 @@ class CobolUnit implements CobolTestFramework{
return this.configuration.absoluteUnitTestFrameworkPath(this.getClass().getSimpleName())
}

private String frameworkBase() {
return this.frameworkBin()
}

private String getParent(String path) {
File file = new File(path)
return file.getParent()
Expand Down
Expand Up @@ -32,13 +32,36 @@ class CobolUnitIntegration implements CobolTestFramework{
private final static DEFAULT_CONF_NAME = 'DEFAULT.CONF'
private String pluginName = null
private Map<CobolUnitSourceFile, List<String>> coverageOutput
private ZUTZCPC zutzcpc = null
private ZUTZCPC zutzcpc

@Override
void configure(CobolExtension configuration, Project project) {
this.configuration = configuration
this.project = project

ZUTZCPC zutzcpcInstance = new ZUTZCPC(this.frameworkBase(), this.configuration)
this.zutzcpc = zutzcpcInstance

/**
* Maybe the precompiler task is already defined (by the unittest->configure)
*/
if(!project.tasks.findByName('compileZUTZCPC')){
this.project.task('compileZUTZCPC', type:CompileZUTZCPC){
project = project
zutzcpc = zutzcpcInstance
}
}
/**
* Add dependency for the precompiler (zutzcpc)
*/
this.project.tasks.testIntegration.dependsOn << this.project.tasks.compileZUTZCPC

/**
* Build all cobol source files as module with code coverage option
*/
this.project.tasks.testIntegration.dependsOn << this.project.tasks.buildDebugWithTracing


this.project.task('computeIntegrationTestCoverage', type:ComputeTestCoverageTask){

group: 'COBOL Development'
Expand All @@ -54,10 +77,6 @@ class CobolUnitIntegration implements CobolTestFramework{

@Override
int prepare() {
logger.info('Setup ZUTZCPC test framework')
this.zutzcpc = new ZUTZCPC(this.frameworkBin(), this.configuration)
this.zutzcpc.setup()

logger.info('Create default test.conf')
this.createTestConf()
return 0
Expand All @@ -75,7 +94,7 @@ class CobolUnitIntegration implements CobolTestFramework{
}

private String defaultConfPath() {
return this.frameworkBin() + '/' + DEFAULT_CONF_NAME
return this.frameworkBase() + '/' + DEFAULT_CONF_NAME
}

@Override
Expand Down Expand Up @@ -130,7 +149,7 @@ class CobolUnitIntegration implements CobolTestFramework{
}

logger.info('Compile Test: ' + unitSourceFile.actualTestfilePath())
new TestDebugCompiler(this.configuration, this.frameworkBin()).compileTest(unitSourceFile)
new TestDebugCompiler(this.configuration, this.frameworkBase()).compileTest(unitSourceFile)
logger.info('Run Test: ' + unitSourceFile.actualTestfilePath())
String result = new TestDebugExecutor(this.configuration).executeTest(unitSourceFile)

Expand All @@ -148,8 +167,12 @@ class CobolUnitIntegration implements CobolTestFramework{
return parser.parse(file, lines)
}

private String frameworkBase() {
return this.configuration.absoluteUnitTestFrameworkPath(CobolUnit.getSimpleName()) + '/'
}

private String frameworkBin() {
return this.configuration.absoluteUnitTestFrameworkPath(CobolUnit.getSimpleName()) + '/integration'
return this.frameworkBase()+ 'integration'
}

private String testBin(CobolSourceFile test) {
Expand Down
@@ -0,0 +1,26 @@
package de.sebastianruziczka.cobolunit

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.OutputFiles
import org.gradle.api.tasks.TaskAction

import de.sebastianruziczka.cobolunit.steps.ZUTZCPC

class CompileZUTZCPC extends DefaultTask {

ZUTZCPC zutzcpcInstance = new ZUTZCPC(project.getExtensions().getByName('cobol').absoluteUnitTestFrameworkPath(CobolUnit.getSimpleName()) , project.getExtensions().getByName('cobol'))

@OutputFiles
public Map<String, File> getInstance() {
HashMap<String, File> files = new HashMap<>()
this.zutzcpcInstance.outputFilePaths().each{
files.put(it, project.file(it))
}
return files
}

@TaskAction
public void compile() {
zutzcpcInstance.setup()
}
}
Expand Up @@ -56,10 +56,18 @@ class ZUTZCPC {
return this.path + '/' + MAIN_FRAMEWORK_PROGRAMM
}

private String frameworkBinPath() {
public String frameworkBinPath() {
return this.path + '/' + MAIN_FRAMEWORK_BIN
}

public def outputFilePaths() {
return [
this.frameworkBinPath(),
this.path + '/ZUTZCPD.CPY',
this.path +'/ZUTZCWS.CPY'
]
}

private int compileTestFramework() {
return this.configuration.compiler
.buildExecutable(this.configuration)
Expand Down

0 comments on commit 7f6cfc9

Please sign in to comment.