Skip to content

Commit

Permalink
Annotate logDocuments with Console and configurations with Claspath
Browse files Browse the repository at this point in the history
  • Loading branch information
ysb33r committed Jul 25, 2018
1 parent 4ac974c commit db01d93
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
*/
package org.asciidoctor.gradle.compat

import org.apache.commons.io.FileUtils
import org.asciidoctor.gradle.internal.FunctionalSpecification
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.IgnoreIf

/**
* This was first functional specification. It is now the functional sepcification to ensure that
Expand All @@ -48,7 +43,7 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {
}

void 'Should do nothing with an empty project'() {
given: "A minimal build file"
given: 'A minimal build file'
getBuildFile('''
asciidoctor {
sourceDir 'non-existing'
Expand All @@ -71,8 +66,8 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {

then:
result.task(ASCIIDOCTOR_PATH).outcome == TaskOutcome.SUCCESS
new File(buildDir, "asciidoc/html5/sample.html").exists()
new File(buildDir, "asciidoc/html5/subdir/sample2.html").exists()
new File(buildDir, 'asciidoc/html5/sample.html').exists()
new File(buildDir, 'asciidoc/html5/subdir/sample2.html').exists()
}

void 'Task should be up-to-date when executed a second time'() {
Expand Down Expand Up @@ -100,7 +95,7 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {

when:
runGradle()
BuildResult result = getGradleRunner([ASCIIDOCTOR_TASK,'-PmodifyClasspath']).build()
BuildResult result = getGradleRunner([ASCIIDOCTOR_TASK, '-PmodifyClasspath']).build()

then:
result.task(ASCIIDOCTOR_PATH).outcome == TaskOutcome.SUCCESS
Expand Down Expand Up @@ -154,7 +149,9 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {
runGradle()

then:
!new File(buildDir,'asciidoctor/html5').listFiles({ !it.directory && !(it.name =~ DOCINFO_FILE_PATTERN) } as FileFilter)
!new File(buildDir, 'asciidoctor/html5').listFiles({
!it.directory && !(it.name =~ DOCINFO_FILE_PATTERN)
} as FileFilter)
}

void 'When resources not specified, then copy all images to backend'() {
Expand All @@ -171,8 +168,8 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {
runGradle()

then:
new File(buildDir,'asciidoc/html5/images/fake.txt').exists()
new File(buildDir,'asciidoc/html5/images/fake2.txt').exists()
new File(buildDir, 'asciidoc/html5/images/fake.txt').exists()
new File(buildDir, 'asciidoc/html5/images/fake2.txt').exists()
}

void 'When resources are specified, then copy images according to patterns'() {
Expand All @@ -195,8 +192,8 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {

then:
verifyAll {
!new File(buildDir,'asciidoc/html5/images/fake.txt').exists()
new File(buildDir,'asciidoc/html5/images/fake2.txt').exists()
!new File(buildDir, 'asciidoc/html5/images/fake.txt').exists()
new File(buildDir, 'asciidoc/html5/images/fake2.txt').exists()
new File(buildDir, 'asciidoc/html5/sample.html').exists()
}
}
Expand All @@ -217,7 +214,7 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {
then:
verifyAll {
result.task(ASCIIDOCTOR_PATH).outcome == TaskOutcome.NO_SOURCE
!new File(buildDir,'asciidoc/html5/subdir/_include.html').exists()
!new File(buildDir, 'asciidoc/html5/subdir/_include.html').exists()
}
}

Expand All @@ -231,11 +228,11 @@ class AsciidoctorFunctionalSpec extends FunctionalSpecification {
)
}

BuildResult runGradle( List<String> args = ['asciidoctor']) {
BuildResult runGradle(List<String> args = ['asciidoctor']) {
getGradleRunner(args).build()
}

BuildResult failedGradle( List<String> args = ['asciidoctor']) {
BuildResult failedGradle(List<String> args = ['asciidoctor', '-i']) {
getGradleRunner(args).buildAndFail()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AsciidoctorCompatibilityTask extends DefaultTask {
*
*/
@Optional
@Internal
@Console
boolean logDocuments = false

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import org.ysb33r.grolifant.api.StringUtils
import java.nio.file.Path

import static org.asciidoctor.gradle.internal.AsciidoctorUtils.*
import static org.gradle.api.tasks.PathSensitivity.RELATIVE
import static org.gradle.workers.IsolationMode.CLASSLOADER
import static org.gradle.workers.IsolationMode.PROCESS

Expand Down Expand Up @@ -91,7 +92,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
/** Logs documents as they are converted
*
*/
@Internal
@Console
boolean logDocuments = false

/** Run Asciidoctor conversions in or out of process
Expand Down Expand Up @@ -190,6 +191,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
*/
@InputFiles
@SkipWhenEmpty
@PathSensitive(RELATIVE)
FileTree getSourceFileTree() {
getSourceFileTreeFrom(sourceDir)
}
Expand Down Expand Up @@ -231,6 +233,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
*
*/
@InputFiles
@PathSensitive(RELATIVE)
FileTree getSecondarySourceFileTree() {
getSecondarySourceFileTreeFrom(sourceDir)
}
Expand Down Expand Up @@ -420,7 +423,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
*
* @return FileCollection
*/
@InputFiles
@Classpath
@SuppressWarnings('Instanceof')
FileCollection getConfigurations() {
FileCollection fc = asciidoctorj.configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class OutputOptions {
*
* @return Set of backends.
*/
@Input
Set<String> getBackends() {
this.backends.empty ? ['html5'].toSet() : this.backends
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AsciidoctorTaskSpec extends Specification {
outputDir = outDir
}

Set<File> files = task.getSourceFileTree().files
Set<File> files = task.sourceFileTree.files

then:
files.find { it.name == '_include.adoc'} == null
Expand Down Expand Up @@ -185,8 +185,6 @@ class AsciidoctorTaskSpec extends Specification {
task.attributes['idprefix'] == '$'
task.options['eruby'] == 'erubis'
task.options['doctype'] == 'book'
// @Ignore('Wrong sysout capture')
// systemOut.toString().contains('Attributes found in options.')
}
@SuppressWarnings('MethodName')
Expand Down Expand Up @@ -452,8 +450,8 @@ class AsciidoctorTaskSpec extends Specification {
]
}
Map options = task.getOptions()
Map attrs = task.getAttributes()
Map options = task.options
Map attrs = task.attributes
expect:
verifyAll {
Expand All @@ -475,7 +473,7 @@ class AsciidoctorTaskSpec extends Specification {
void "Throws exception when attributes embedded in options is an unsupported type"() {
when:
AsciidoctorTask task = project.tasks.create(name: ASCIIDOCTOR, type: AsciidoctorTask) {
project.tasks.create(name: ASCIIDOCTOR, type: AsciidoctorTask) {
options = [
attributes: 23
]
Expand All @@ -496,8 +494,9 @@ class AsciidoctorTaskSpec extends Specification {
foo: "${variable}"
]
}
Map options = task.getOptions()
Map attrs = task.getAttributes()
Map options = task.options
Map attrs = task.attributes
expect:
verifyAll {
Expand All @@ -508,7 +507,6 @@ class AsciidoctorTaskSpec extends Specification {
options.template_dirs[0].endsWith('haml')
attrs.'foo' == variable
}
}
void 'Safe mode option is equal to level of SafeMode.UNSAFE by default'() {
Expand Down

0 comments on commit db01d93

Please sign in to comment.