@@ -16,22 +16,20 @@ const TESTS_FOLDERS = [
1616
1717const REGEX_PATTERN_HIDDEN_FILES = / ( ^ | \/ ) \. [ ^ \/ \. ] / g;
1818
19- const get_all_tests = async function ( paths ) {
19+ const getAllTests = async function ( paths ) {
2020 let problems = [ ] ;
2121 for ( const i in paths ) {
2222 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 ) ;
2525 }
2626 return problems ;
2727} ;
2828
29- const test_all = async function ( ) {
29+ const runAllTests = async function ( problems ) {
3030 try {
31-
32- const problems = await get_all_tests ( TESTS_FOLDERS ) ;
3331 console . log ( problems ) ;
34- var solvePromises = problems . map ( solve ) ;
32+ var solvePromises = problems . map ( solveProblem ) ;
3533
3634 await Promise . all ( solvePromises ) ;
3735 } catch ( error ) {
@@ -40,7 +38,7 @@ const test_all = async function () {
4038 }
4139} ;
4240
43- const solve = ( problem ) => {
41+ const solveProblem = ( problem ) => {
4442 try {
4543 console . log ( "Solving: " + problem ) ;
4644
@@ -67,19 +65,16 @@ const loadProblemsFiles = (folder) => {
6765 reject ( error ) ;
6866 } else {
6967 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 ) ;
7270
73- resolve ( new_problems ) ;
71+ resolve ( newProblems ) ;
7472 }
7573 } ) ;
7674 } ) ;
7775} ;
7876
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 ) {
8378 const hasTestStatus = problems . reduce ( ( status , problemPath ) => {
8479 const baseIndex = PROBLEMS_FOLDERS . findIndex ( ( basePath ) =>
8580 problemPath . startsWith ( basePath )
@@ -105,11 +100,17 @@ const get_missing_tests = async function () {
105100 }
106101} ;
107102
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+ }
114114}
115-
115+
116+ runScript ( ) ;
0 commit comments