Skip to content
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

Set Junit5 as default test engine #1187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Build
strategy:
fail-fast: false
max-parallel: 4
max-parallel: 6
matrix:
java:
- '11'
Expand All @@ -39,7 +39,6 @@ jobs:
./gradlew -S -Pskip.signing check
build-windows:
name: Build on Windows
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 3
Expand All @@ -48,6 +47,9 @@ jobs:
- '11'
- '17'
- '19'
os:
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -64,6 +66,24 @@ jobs:
shell: cmd
run: |
gradlew.bat -i -S check
- name: Upload asciidoctorj-core reports
uses: actions/upload-artifact@v3
env:
os_name: ${{ matrix.os }}
java_version: ${{ matrix.java }}
if: always()
with:
name: asciidoctorj-core-reports-${{ env.os_name }}-${{ env.java_version }}
path: asciidoctorj-core/build/reports/*
- name: Upload asciidoctorj-documentation reports
uses: actions/upload-artifact@v3
if: always()
env:
os_name: ${{ matrix.os }}
java_version: ${{ matrix.java }}
with:
name: asciidoctorj-documentation-reports-${{ env.os_name }}-${{ env.java_version }}
path: asciidoctorj-documentation/build/reports/*
test-asciidoctor-upstream:
name: Test Asciidoctor Upstream
needs:
Expand All @@ -88,16 +108,19 @@ jobs:
- name: Setup Java
uses: s4u/setup-maven-action@v1.7.0
with:
distribution: temurin
java-distribution: temurin
java-version: ${{ matrix.java }}
maven-version: ${{ matrix.maven }}
- name: Upstream Build
run: |
unset GEM_PATH GEM_HOME JRUBY_OPTS
./ci/test-asciidoctor-upstream.sh
- name: Upload reports
- name: Upload asciidoctorj-core reports
uses: actions/upload-artifact@v3
if: always()
env:
os_name: ${{ matrix.os }}
java_version: ${{ matrix.java }}
with:
name: asciidoctorj-core-reports
name: asciidoctorj-core-reports-upstream-${{ env.os_name }}-${{ env.java_version }}
path: asciidoctorj-core/build/reports/*
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Build Improvement::
* Run tests on Java 19 (#1563)
* Fix upstream tests forcing SNAPSHOT on Asciidoctor gem installation (#1123) (@abelsromero)
* Fix upstream build removing the explicit plugin repository (#1131)
* Set JUnit5 as default test engine (#1186) (@abelsromero)

== 2.5.4 (2022-06-30)

Expand Down
4 changes: 3 additions & 1 deletion asciidoctorj-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ dependencies {
api project(':asciidoctorj')
implementation "com.beust:jcommander:$jcommanderVersion"

testImplementation project(':asciidoctorj-arquillian-extension')
testImplementation (project(':asciidoctorj-test-support')) {
exclude group: 'junit', module: 'junit'
}
testImplementation "org.jsoup:jsoup:$jsoupVersion"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.beust.jcommander.JCommander;
import org.asciidoctor.SafeMode;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package org.asciidoctor.cli;

import org.asciidoctor.cli.jruby.AsciidoctorInvoker;
import org.asciidoctor.util.ClasspathResources;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.asciidoctor.util.ClasspathHelper;
import org.assertj.core.api.Assertions;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import static org.assertj.core.api.Assertions.catchThrowable;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.core.StringStartsWith.startsWith;

@RunWith(Arquillian.class)
public class WhenAsciidoctorIsCalledUsingCli {

private static final String SAMPLE_FILE = "rendersample.asciidoc";
Expand All @@ -31,14 +30,19 @@ public class WhenAsciidoctorIsCalledUsingCli {

private static final String SOURCE_EXTENSION_PATTERN = "\\.asciidoc$";

@ArquillianResource
private ClasspathResources classpath;
private static ClasspathHelper classpath;

@ArquillianResource
public TemporaryFolder temporaryFolder;
@TempDir
public File temporaryFolder;

public String pwd = new File("").getAbsolutePath();

@BeforeAll
static void beforeAll() {
classpath = new ClasspathHelper();
classpath.setClassloader(WhenAsciidoctorIsCalledUsingCli.class);
}

@Test
public void with_no_options_file_should_be_rendered_in_place_and_in_html5_format() throws IOException {
File inputFile = classpath.getResource(SAMPLE_FILE);
Expand Down Expand Up @@ -116,7 +120,7 @@ public void composed_attributes_should_be_built_as_attributes_map() throws IOExc

@Test
public void destination_dir_should_render_files_to_ouput_directory() throws IOException {
File outputDirectory = temporaryFolder.getRoot();
File outputDirectory = temporaryFolder;

File inputFile = classpath.getResource(SAMPLE_FILE);
String inputPath = inputFile.getPath().substring(pwd.length() + 1);
Expand All @@ -127,9 +131,12 @@ public void destination_dir_should_render_files_to_ouput_directory() throws IOEx
}


@Test(expected = IllegalArgumentException.class)
public void empty_input_file_name_should_throw_an_exception() throws IOException {
new AsciidoctorInvoker().invoke("");
@Test
public void empty_input_file_name_should_throw_an_exception() {
Throwable throwable = catchThrowable(() -> new AsciidoctorInvoker().invoke(""));

Assertions.assertThat(throwable)
.isInstanceOf(IllegalArgumentException.class);
}

@Test
Expand All @@ -145,9 +152,12 @@ public void version_flag_should_print_version_and_exit() throws IOException {
assertThat(os.toString(), startsWith("Asciidoctor"));
}

@Test(expected = IllegalArgumentException.class)
public void invalid_input_file_should_throw_an_exception() throws IOException {
new AsciidoctorInvoker().invoke("myunknown.adoc");
@Test
public void invalid_input_file_should_throw_an_exception() {
Throwable throwable = catchThrowable(() -> new AsciidoctorInvoker().invoke("myunknown.adoc"));

Assertions.assertThat(throwable)
.isInstanceOf(IllegalArgumentException.class);
}

@Test
Expand Down
14 changes: 5 additions & 9 deletions asciidoctorj-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tasks.eclipse.dependsOn jrubyPrepare

jruby {
defaultRepositories = false
defaultVersion = jrubyVersion
jrubyVersion = jrubyVersion
// TODO I'd like to be able to customize the name of the gemInstallDir
}

Expand Down Expand Up @@ -86,10 +86,6 @@ javadoc {
source(project(':asciidoctorj-api').sourceSets.main.allJava)
}

//jruby {
// execVersion = '1.7.20'
//}

jar {
bnd(
('Bundle-Name'): 'asciidoctorj',
Expand All @@ -99,8 +95,8 @@ jar {
}

test {
useJUnit {
excludeCategories 'org.asciidoctor.categories.Polluted'
useJUnitPlatform() {
excludeTags("polluted")
}
}

Expand All @@ -119,8 +115,8 @@ version.asciidoctor: $asciidoctorGemVersion
jar.dependsOn createVersionFile

task pollutedTest(type: Test) {
useJUnit {
includeCategories 'org.asciidoctor.categories.Polluted'
useJUnitPlatform() {
includeTags 'polluted'
}
forkEvery = 10
minHeapSize = '128m'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ import org.asciidoctor.ast.Document
import org.asciidoctor.ast.ListItem
import org.asciidoctor.converter.StringConverter
import org.asciidoctor.extension.Treeprocessor
import org.jboss.arquillian.spock.ArquillianSputnik
import org.jboss.arquillian.test.api.ArquillianResource
import org.jsoup.Jsoup
import org.junit.runner.RunWith
import spock.lang.Specification

@RunWith(ArquillianSputnik)
class WhenADocumentContainsADefinitionList extends Specification {

static final String TAG_DD = 'dd'

@ArquillianResource
private Asciidoctor asciidoctor
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()

def "the definition list should be loaded"() {

Expand Down Expand Up @@ -170,6 +165,6 @@ Item A::
then:
org.jsoup.nodes.Document htmlDoc = Jsoup.parse(result)
htmlDoc.getElementsByTag(TAG_DD).size() == 1
htmlDoc.getElementsByTag(TAG_DD)[0].text() == newDescription
htmlDoc.getElementsByTag(TAG_DD)[0].text() == newDescription
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package org.asciidoctor

import org.asciidoctor.ast.Section
import org.jboss.arquillian.spock.ArquillianSputnik
import org.jboss.arquillian.test.api.ArquillianResource
import org.junit.runner.RunWith
import spock.lang.Specification

@RunWith(ArquillianSputnik)
class WhenADocumentContainsNumberedSections extends Specification {

@ArquillianResource
private Asciidoctor asciidoctor
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()

def "for appendix the section numeral should be a letter"() {
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@ import org.asciidoctor.ast.ContentNode
import org.asciidoctor.ast.Document
import org.asciidoctor.ast.Section
import org.asciidoctor.converter.StringConverter
import org.jboss.arquillian.spock.ArquillianSputnik
import org.jboss.arquillian.test.api.ArquillianResource
import org.junit.runner.RunWith
import spock.lang.Specification

@RunWith(ArquillianSputnik)
class WhenADocumentIsRenderedToStream extends Specification {

public static final String HTML5_BACKEND = 'html5'
public static final String HELLO_WORLD = 'Hello World'
public static final String EMPTY_STRING = ''

@ArquillianResource
private Asciidoctor asciidoctor
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()

static final String TEST_DOC = '''= Test

Expand Down Expand Up @@ -106,6 +101,7 @@ Hello, World!
TestConverter(String backend, Map<String, Object> opts) {
super(backend, opts)
}

@Override
String convert(ContentNode node, String transform, Map<Object, Object> opts) {
if (transform == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ package org.asciidoctor

import org.asciidoctor.ast.Document
import org.asciidoctor.ast.Table
import org.jboss.arquillian.spock.ArquillianSputnik
import org.jboss.arquillian.test.api.ArquillianResource
import org.jruby.exceptions.RaiseException
import org.junit.runner.RunWith

import spock.lang.Specification

@RunWith(ArquillianSputnik)
class WhenATableIsLoaded extends Specification {


@ArquillianResource
private Asciidoctor asciidoctor
private Asciidoctor asciidoctor = Asciidoctor.Factory.create()

def "colspan greater 1 should be passed correctly to the nodes"() {

Expand Down Expand Up @@ -57,10 +50,10 @@ class WhenATableIsLoaded extends Specification {
tableNode.body[0].cells[0].colspan == 0
}

def "asking a table cell for its inner document when it does not have one should return null"() {
def "asking a table cell for its inner document when it does not have one should return null"() {

given:
String document = '''= Test document
given:
String document = '''= Test document

[cols="40,60"]
|===
Expand All @@ -77,13 +70,13 @@ The second content cell
|===
'''

when:
Document documentNode = asciidoctor.load(document, OptionsBuilder.options().standalone(false).asMap())
Table tableNode = documentNode.blocks[0]
when:
Document documentNode = asciidoctor.load(document, OptionsBuilder.options().standalone(false).asMap())
Table tableNode = documentNode.blocks[0]

then:
tableNode.header[0].cells[0].innerDocument == null
tableNode.header[0].cells[1].innerDocument == null
notThrown(RaiseException)
}
then:
tableNode.header[0].cells[0].innerDocument == null
tableNode.header[0].cells[1].innerDocument == null
notThrown(RaiseException)
}
}
Loading