File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ object Wc3ClientDetector {
7878
7979 private fun findExecutable (root : Path ): Path ? {
8080 if (Files .isRegularFile(root)) {
81- return root
81+ return root. takeIf { classifyExecutable(it) != null }
8282 }
8383 return exeCandidates
8484 .map { root.resolve(it) }
Original file line number Diff line number Diff line change @@ -37,6 +37,29 @@ class Wc3ClientDetectorTests {
3737 Assert .assertEquals(info.kind, Wc3ClientDetector .ClientKind .CLASSIC )
3838 }
3939
40+ @Test
41+ fun testRejectsUnsupportedExplicitFilePath () {
42+ val root = Files .createTempDirectory(" wc3-explicit-file" )
43+ val textFile = root.resolve(" notes.txt" )
44+ Files .writeString(textFile, " not a wc3 executable" )
45+
46+ val info = Wc3ClientDetector .inspectGameRoot(textFile)
47+
48+ Assert .assertNull(info)
49+ }
50+
51+ @Test
52+ fun testAcceptsSupportedExplicitFilePath () {
53+ val root = Files .createTempDirectory(" wc3-explicit-exe" )
54+ val exe = root.resolve(" war3.exe" )
55+ Files .writeString(exe, " " )
56+
57+ val info = Wc3ClientDetector .inspectGameRoot(exe)!!
58+
59+ Assert .assertEquals(info.kind, Wc3ClientDetector .ClientKind .PRE_129 )
60+ Assert .assertEquals(info.root, root.toAbsolutePath().normalize())
61+ }
62+
4063 @Test
4164 fun testWarnsWhenProjectPatchAndClientKindDiffer () {
4265 val root = Files .createTempDirectory(" wc3-mismatch" )
You can’t perform that action at this time.
0 commit comments