Skip to content

Commit 5ecf9a4

Browse files
committed
🐛 correctly resolve paths that don't start with file
1 parent 282e384 commit 5ecf9a4

File tree

4 files changed

+49
-23
lines changed

4 files changed

+49
-23
lines changed

.github/workflows/tools-data.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
id: test-data-check
3939
uses: actions/cache@v4.0.0
4040
with:
41-
path: sources/5etools-mirror-2.github.io
41+
path: sources
4242
key: ${{ steps.test-data-key.outputs.cache_key }}
4343
lookup-only: true
4444
enableCrossOsArchive: true
@@ -86,7 +86,7 @@ jobs:
8686
- uses: actions/cache/restore@v4.0.0
8787
id: cache
8888
with:
89-
path: sources/5etools-mirror-2.github.io
89+
path: sources
9090
key: ${{ needs.cache-setup.outputs.cache_key }}
9191
fail-on-cache-miss: true
9292

@@ -100,6 +100,7 @@ jobs:
100100
- name: Build with Maven
101101
id: mvn-build
102102
run: |
103+
ls -al sources
103104
./mvnw -B -ntp -DskipFormat verify
104105
105106
native-test-with-data:

src/main/java/dev/ebullient/convert/config/TtrpgConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private ImageRoot(String cfgRoot, ImageOptions options) {
103103
this.internalImageRoot = "";
104104
this.copyInternal = false;
105105
} else {
106-
if (cfgRoot.startsWith("http") || !cfgRoot.startsWith("file:")) {
106+
if (cfgRoot.startsWith("http") || cfgRoot.startsWith("file:")) {
107107
this.internalImageRoot = endWithSlash(cfgRoot);
108108
} else {
109109
Path imgPath = Path.of("").resolve(cfgRoot).normalize().toAbsolutePath();

src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public class Tools5eDataConvertTest {
2222
@BeforeAll
2323
public static void setupDir() {
2424
setupDir("Tools5eDataConvertTest");
25+
26+
tui.printlnf("5eTools sources (%s): %s",
27+
TestUtils.PATH_5E_TOOLS_DATA.toFile().exists(),
28+
TestUtils.PATH_5E_TOOLS_DATA);
29+
tui.printlnf("5eTools images (%s): %s",
30+
TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists(),
31+
TestUtils.PATH_5E_TOOLS_IMAGES);
32+
tui.printlnf("5eTools homebrew (%s): %s",
33+
TestUtils.PATH_5E_HOMEBREW.toFile().exists(),
34+
TestUtils.PATH_5E_HOMEBREW);
2535
}
2636

2737
public static void setupDir(String root) {
@@ -68,9 +78,14 @@ void testLiveData_5eAllSources(QuarkusMainLauncher launcher) {
6878
List<String> args = new ArrayList<>(List.of("--index", "--debug",
6979
"-c", TestUtils.TEST_RESOURCES.resolve("sources-images.yaml").toString(),
7080
"-o", allIndex.toString(),
71-
TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString(),
7281
TestUtils.PATH_5E_TOOLS_DATA.toString()));
7382

83+
if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
84+
args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
85+
} else {
86+
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
87+
}
88+
7489
args.addAll(TestUtils.getFilesFrom(TestUtils.PATH_5E_TOOLS_DATA.resolve("adventure")));
7590
args.addAll(TestUtils.getFilesFrom(TestUtils.PATH_5E_TOOLS_DATA.resolve("book")));
7691

@@ -127,12 +142,18 @@ void testLiveData_5eHomebrew(QuarkusMainLauncher launcher) {
127142
Path target = testOutput.resolve("homebrew");
128143
TestUtils.deleteDir(target);
129144

130-
LaunchResult result = launcher.launch("--debug", "--index", "--log",
145+
List<String> args = new ArrayList<>(List.of("--debug", "--index", "--log",
131146
"-c", TestUtils.TEST_RESOURCES.resolve("sources-homebrew.json").toString(),
132147
"-o", target.toString(),
133-
TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString(),
134-
TestUtils.PATH_5E_TOOLS_DATA.toString());
148+
TestUtils.PATH_5E_TOOLS_DATA.toString()));
149+
150+
if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
151+
args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
152+
} else {
153+
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
154+
}
135155

156+
LaunchResult result = launcher.launch(args.toArray(new String[0]));
136157
assertThat(result.exitCode())
137158
.withFailMessage("Command failed. Output:%n%s", TestUtils.dump(result))
138159
.isEqualTo(0);

src/test/java/dev/ebullient/convert/tools/dnd5e/CommonDataTests.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import com.fasterxml.jackson.databind.JsonNode;
1414
import com.fasterxml.jackson.databind.node.ArrayNode;
15-
import com.fasterxml.jackson.databind.node.ObjectNode;
1615

1716
import dev.ebullient.convert.TestUtils;
1817
import dev.ebullient.convert.config.CompendiumConfig;
@@ -63,10 +62,7 @@ public CommonDataTests(TestInput variant, Path toolsData) throws Exception {
6362

6463
configurator = new Configurator(tui);
6564
if (imgPresent) {
66-
ObjectNode images = Tui.MAPPER.createObjectNode()
67-
.put("copyInternal", true)
68-
.put("internalRoot", TestUtils.PATH_5E_TOOLS_IMAGES.toString());
69-
configurator.readConfigIfPresent(Tui.MAPPER.createObjectNode().set("images", images));
65+
configurator.readConfiguration(TestUtils.TEST_RESOURCES.resolve("images-from-local.json"));
7066
} else {
7167
configurator.readConfiguration(TestUtils.TEST_RESOURCES.resolve("images-remote.json"));
7268
}
@@ -194,8 +190,10 @@ public void testDeckList(Path outputPath) {
194190
.writeImages();
195191

196192
TestUtils.assertDirectoryContents(outDir, tui);
197-
Path imageDir = outDir.resolve("img");
198-
assertThat(imageDir).isDirectory();
193+
if (imgPresent) {
194+
Path imageDir = outDir.resolve("img");
195+
assertThat(imageDir).isDirectory();
196+
}
199197

200198
List<Path> srd = List.of(outDir.resolve("deck-of-illusions.md"), outDir.resolve("deck-of-many-things.md"));
201199
List<Path> some = List.of(outDir.resolve("roleplaying-cards-wbtw.md"));
@@ -222,11 +220,13 @@ public void testDeityList(Path outputPath) {
222220
List<Path> all = List.of(outDir.resolve("exandria-lolth.md"));
223221
testVariants(srd, some, all);
224222

225-
Path imageDir = outDir.resolve("img");
226-
if (variant == TestInput.none) {
227-
assertThat(imageDir).doesNotExist();
228-
} else {
229-
assertThat(imageDir).isDirectory();
223+
if (imgPresent) {
224+
Path imageDir = outDir.resolve("img");
225+
if (variant == TestInput.none) {
226+
assertThat(imageDir).doesNotExist();
227+
} else {
228+
assertThat(imageDir).isDirectory();
229+
}
230230
}
231231
TestUtils.assertDirectoryContents(outDir, tui);
232232
}
@@ -273,8 +273,10 @@ public void testMonsterList(Path outputPath) {
273273
.writeFiles(List.of(Tools5eIndexType.monster, Tools5eIndexType.legendaryGroup))
274274
.writeImages();
275275

276-
Path tokenDir = bestiaryDir.resolve("undead/token");
277-
assertThat(tokenDir.toFile()).exists();
276+
if (imgPresent) {
277+
Path tokenDir = bestiaryDir.resolve("undead/token");
278+
assertThat(tokenDir.toFile()).exists();
279+
}
278280

279281
Path lgDir = bestiaryDir.resolve("legendary-group");
280282
if (variant == TestInput.none) {
@@ -436,8 +438,10 @@ public void testObjectList(Path outputPath) {
436438
Tools5eIndexType.object))
437439
.writeImages();
438440

439-
Path imageDir = outDir.resolve("token");
440-
assertThat(imageDir).exists();
441+
if (imgPresent) {
442+
Path imageDir = outDir.resolve("token");
443+
assertThat(imageDir).exists();
444+
}
441445

442446
List<Path> srd = List.of(outDir.resolve("generic-object.md"));
443447
List<Path> some = List.of(outDir.resolve("ballista.md"));

0 commit comments

Comments
 (0)