File tree Expand file tree Collapse file tree 2 files changed +42
-39
lines changed
Expand file tree Collapse file tree 2 files changed +42
-39
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ package internal
22
33import (
44 "fmt"
5- "os"
6- "path/filepath"
75
86 chess_bot_executable "github.com/codecrafters-io/gleam-chess-bot-tester/internal/chess-bot-executable"
97 "github.com/codecrafters-io/tester-utils/test_case_harness"
@@ -28,40 +26,3 @@ func test5(stageHarness *test_case_harness.TestCaseHarness) error {
2826
2927 return nil
3028}
31-
32- func checkForEntryMd (files []os.DirEntry ) bool {
33- return checkForFile (files , "ENTRY.md" )
34- }
35-
36- func checkForExampleEntryMd (files []os.DirEntry ) bool {
37- return checkForFile (files , "example.ENTRY.md" )
38- }
39-
40- func checkForEitherExampleOrEntryMd (files []os.DirEntry ) bool {
41- return checkForExampleEntryMd (files ) || checkForEntryMd (files )
42- }
43-
44- func listFilesInExecutableDir (stageHarness * test_case_harness.TestCaseHarness ) ([]os.DirEntry , error ) {
45- executablePath := stageHarness .Executable .Path
46- executableDir := filepath .Dir (executablePath )
47-
48- files , err := os .ReadDir (executableDir )
49- if err != nil {
50- return nil , err
51- }
52-
53- return files , nil
54- }
55-
56- func checkForFile (files []os.DirEntry , fileName string ) bool {
57- if len (files ) == 0 {
58- return false
59- }
60-
61- for _ , file := range files {
62- if file .Name () == fileName {
63- return true
64- }
65- }
66- return false
67- }
Original file line number Diff line number Diff line change @@ -6,8 +6,11 @@ import (
66 "fmt"
77 "io"
88 "net/http"
9+ "os"
10+ "path/filepath"
911 "time"
1012
13+ "github.com/codecrafters-io/tester-utils/test_case_harness"
1114 "github.com/corentings/chess"
1215)
1316
@@ -77,3 +80,42 @@ func checkFEN(FEN string) bool {
7780 }
7881 return err == nil
7982}
83+
84+ // File utils to check for the existence of entry files in the repo
85+
86+ func checkForEntryMd (files []os.DirEntry ) bool {
87+ return checkForFile (files , "ENTRY.md" )
88+ }
89+
90+ func checkForExampleEntryMd (files []os.DirEntry ) bool {
91+ return checkForFile (files , "example.ENTRY.md" )
92+ }
93+
94+ func checkForEitherExampleOrEntryMd (files []os.DirEntry ) bool {
95+ return checkForExampleEntryMd (files ) || checkForEntryMd (files )
96+ }
97+
98+ func listFilesInExecutableDir (stageHarness * test_case_harness.TestCaseHarness ) ([]os.DirEntry , error ) {
99+ executablePath := stageHarness .Executable .Path
100+ executableDir := filepath .Dir (executablePath )
101+
102+ files , err := os .ReadDir (executableDir )
103+ if err != nil {
104+ return nil , err
105+ }
106+
107+ return files , nil
108+ }
109+
110+ func checkForFile (files []os.DirEntry , fileName string ) bool {
111+ if len (files ) == 0 {
112+ return false
113+ }
114+
115+ for _ , file := range files {
116+ if file .Name () == fileName {
117+ return true
118+ }
119+ }
120+ return false
121+ }
You can’t perform that action at this time.
0 commit comments