@@ -16,22 +16,20 @@ const TESTS_FOLDERS = [
16
16
17
17
const REGEX_PATTERN_HIDDEN_FILES = / ( ^ | \/ ) \. [ ^ \/ \. ] / g;
18
18
19
- const get_all_tests = async function ( paths ) {
19
+ const getAllTests = async function ( paths ) {
20
20
let problems = [ ] ;
21
21
for ( const i in paths ) {
22
22
const folder = paths [ i ] ;
23
- const new_problems = await loadProblemsFiles ( folder ) ; // await
24
- problems = problems . concat ( new_problems ) ;
23
+ const newProblems = await loadProblemsFiles ( folder ) ; // await
24
+ problems = problems . concat ( newProblems ) ;
25
25
}
26
26
return problems ;
27
27
} ;
28
28
29
- const test_all = async function ( ) {
29
+ const runAllTests = async function ( problems ) {
30
30
try {
31
-
32
- const problems = await get_all_tests ( TESTS_FOLDERS ) ;
33
31
console . log ( problems ) ;
34
- var solvePromises = problems . map ( solve ) ;
32
+ var solvePromises = problems . map ( solveProblem ) ;
35
33
36
34
await Promise . all ( solvePromises ) ;
37
35
} catch ( error ) {
@@ -40,7 +38,7 @@ const test_all = async function () {
40
38
}
41
39
} ;
42
40
43
- const solve = ( problem ) => {
41
+ const solveProblem = ( problem ) => {
44
42
try {
45
43
console . log ( "Solving: " + problem ) ;
46
44
@@ -67,19 +65,16 @@ const loadProblemsFiles = (folder) => {
67
65
reject ( error ) ;
68
66
} else {
69
67
console . log ( folder ) ;
70
- new_problems = files . filter ( ( item ) => ! REGEX_PATTERN_HIDDEN_FILES . test ( item ) ) ;
71
- new_problems = new_problems . map ( ( item ) => folder + item ) ;
68
+ newProblems = files . filter ( ( item ) => ! REGEX_PATTERN_HIDDEN_FILES . test ( item ) ) ;
69
+ newProblems = newProblems . map ( ( item ) => folder + item ) ;
72
70
73
- resolve ( new_problems ) ;
71
+ resolve ( newProblems ) ;
74
72
}
75
73
} ) ;
76
74
} ) ;
77
75
} ;
78
76
79
- const get_missing_tests = async function ( ) {
80
- const tests = await get_all_tests ( TESTS_FOLDERS ) ;
81
- const problems = await get_all_tests ( PROBLEMS_FOLDERS ) ;
82
-
77
+ const getMissingTests = async function ( tests , problems ) {
83
78
const hasTestStatus = problems . reduce ( ( status , problemPath ) => {
84
79
const baseIndex = PROBLEMS_FOLDERS . findIndex ( ( basePath ) =>
85
80
problemPath . startsWith ( basePath )
@@ -105,11 +100,17 @@ const get_missing_tests = async function () {
105
100
}
106
101
} ;
107
102
108
- if ( process . argv . length > 2 ) {
109
- const path = process . argv . pop ( ) ;
110
- solve ( path ) ;
111
- } else {
112
- test_all ( ) ;
113
- get_missing_tests ( ) ;
103
+ async function runScript ( ) {
104
+ if ( process . argv . length > 2 ) {
105
+ const path = process . argv . pop ( ) ;
106
+ solveProblem ( path ) ;
107
+ } else {
108
+ const problems = await getAllTests ( PROBLEMS_FOLDERS ) ;
109
+ const tests = await getAllTests ( TESTS_FOLDERS ) ;
110
+
111
+ await runAllTests ( tests ) ;
112
+ await getMissingTests ( tests , problems ) ;
113
+ }
114
114
}
115
-
115
+
116
+ runScript ( ) ;
0 commit comments