Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import org.itsallcode.openfasttrace.api.importer.*;
import org.itsallcode.openfasttrace.api.importer.input.InputFile;
import org.itsallcode.openfasttrace.api.importer.input.RealFileInput;
import org.itsallcode.openfasttrace.testutil.OsDetector;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
Expand Down Expand Up @@ -59,17 +61,17 @@ void beforeEach()
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testImportWindows()
{
OsDetector.assumeRunningOnWindows();
runImporter();
assertThat(this.fileArg.getValue().getPath(), equalTo("dir\\file"));
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testImportUnix()
{
OsDetector.assumeRunningOnUnix();
runImporter();
assertThat(this.fileArg.getValue().getPath(), equalTo("dir/file"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import org.itsallcode.openfasttrace.api.importer.input.InputFile;
import org.itsallcode.openfasttrace.api.importer.input.RealFileInput;
import org.itsallcode.openfasttrace.api.importer.tag.config.DescribedPathMatcher;
import org.itsallcode.openfasttrace.testutil.OsDetector;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;

class DescribedPathMatcherTest
{
Expand Down Expand Up @@ -47,18 +49,18 @@ void testListBasedMatcherMatchesRelativePath()
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testListBasedMatcherIsCaseInsensitiveUnderWindows()
{
OsDetector.assumeRunningOnWindows();
createListMatcher("rel/path");
assertMatches("REL/path", true);
assertMatches("rel/PATH", true);
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testListBasedMatcherIsCaseSensitiveUnderUnix()
{
OsDetector.assumeRunningOnUnix();
createListMatcher("rel/path");
assertMatches("REL/path", false);
assertMatches("rel/PATH", false);
Expand All @@ -83,17 +85,17 @@ void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithForwardSlash()
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithForwardSlashWindows()
{
OsDetector.assumeRunningOnWindows();
createListMatcher("C:/abs/path");
assertMatches("C:\\abs\\path", true);
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithForwardSlashUnix()
{
OsDetector.assumeRunningOnUnix();
createListMatcher("C:/abs/path");
assertMatches("C:\\abs\\path", false);
}
Expand All @@ -107,18 +109,18 @@ void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithBackslash()
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithBackslashUnix()
{
OsDetector.assumeRunningOnUnix();
createListMatcher("C:\\abs\\path");
assertMatches("C:/abs/path", false);
assertMatches("C:\\abs\\path\\", false);
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testListBasedMatcherMatchesAbsoluteWindowsStylePathWithBackslashWindows()
{
OsDetector.assumeRunningOnWindows();
createListMatcher("C:\\abs\\path");
assertMatches("C:/abs/path", true);
assertMatches("C:\\abs\\path\\", true);
Expand Down
3 changes: 2 additions & 1 deletion doc/changes/changes_4.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ We moved some GitHub action permissions from workflow-level to job-level.

## Refactoring

* #543: Made `CliException` a `RuntimeException`
* #546: Replaced `OsDetector` with JUnit5's `EnabledOnOs` annotation.
* #543: Made `CliException` a `RuntimeException`
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import org.itsallcode.openfasttrace.report.html.view.ViewableContainer;
import org.itsallcode.openfasttrace.report.html.view.html.HtmlViewFactory;
import org.itsallcode.openfasttrace.testutil.AbstractFileBasedTest;
import org.itsallcode.openfasttrace.testutil.OsDetector;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;

class TestHtmlReportCssInlining extends AbstractFileBasedTest
Expand Down Expand Up @@ -48,9 +49,9 @@ void testInliningNonExistentCssThrowsException() throws URISyntaxException, Malf
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testInliningUnreadableCssThrowsException(@TempDir final Path tempDir) throws IOException
{
OsDetector.assumeRunningOnUnix();
final File cssFile = tempDir.resolve("test.css").toFile();
cssFile.setReadable(false);
final HtmlViewFactory factory = HtmlViewFactory.create(new ByteArrayOutputStream(), cssFile.toURI().toURL(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import static org.itsallcode.openfasttrace.report.html.view.html.OriginLinkFormatter.formatAsSpan;

import org.itsallcode.openfasttrace.api.core.Location;
import org.itsallcode.openfasttrace.testutil.OsDetector;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;

class TestOriginLinkFormatter
{
Expand Down Expand Up @@ -66,33 +68,33 @@ void testLongerHttpLink()
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testFormatRegularAbsoluteUnixPath()
{
OsDetector.assumeRunningOnUnix();
assertPathAndLineRenderedToSpan("/foo/bar/baz", 1111,
"<a href=\"file:///foo/bar/baz\">/foo/bar/baz</a>:1111");
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testFormatRegularAbsoluteWindowsPath()
{
OsDetector.assumeRunningOnWindows();
assertPathAndLineRenderedToSpan("C:\\foo\\bar\\baz", 1111,
"<a href=\"file:///C:/foo/bar/baz\">C:\\foo\\bar\\baz</a>:1111");
}

@Test
@EnabledOnOs(OS.LINUX)
void testFormatAbsoluteUnixPathWithSpecialCharactersLinux()
{
OsDetector.assumeRunningOnLinux();
assertPathAndLineRenderedToSpan("/fo o/bär/baz", 12345678,
"<a href=\"file:///fo%20o/b%C3%A4r/baz\">/fo o/bär/baz</a>:12345678");
}

@Test
@EnabledOnOs(OS.MAC)
void testFormatAbsoluteUnixPathWithSpecialCharactersMacOs()
{
OsDetector.assumeRunningOnMacOs();
assertPathAndLineRenderedToSpan("/fo o/bär/baz", 12345678,
"<a href=\"file:///fo%20o/ba%CC%88r/baz\">/fo o/bär/baz</a>:12345678");
}
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading