@@ -43,28 +43,30 @@ func writeLinesToFile(filename string, lines []string) {
43
43
}
44
44
}
45
45
46
- func AddNewCaseInput (input_lines []string ,
47
- case_name string ,
48
- meta_data config.EgorMeta ) (config.EgorMeta , error ) {
46
+ func AddNewCaseInput (inputLines []string ,
47
+ caseName string ,
48
+ metaData config.EgorMeta ,
49
+ noTimeOut bool ) (config.EgorMeta , error ) {
49
50
50
- input_file_name := case_name + ".in"
51
- writeLinesToFile ("inputs/" + input_file_name , input_lines )
52
- input_file := config .NewIoFile (input_file_name , "inputs/" + input_file_name , true )
53
- meta_data .Inputs = append (meta_data .Inputs , input_file )
51
+ inputFileName := caseName + ".in"
52
+ writeLinesToFile (path . Join ( "inputs" , inputFileName ), inputLines )
53
+ inputFile := config .NewIoFile (inputFileName , path . Join ( "inputs" , inputFileName ), true , noTimeOut )
54
+ metaData .Inputs = append (metaData .Inputs , inputFile )
54
55
55
- return meta_data , nil
56
+ return metaData , nil
56
57
}
57
58
58
- func AddNewCaseOutput (output_lines []string ,
59
- case_name string ,
60
- meta_data config.EgorMeta ) (config.EgorMeta , error ) {
59
+ func AddNewCaseOutput (outputLines []string ,
60
+ caseName string ,
61
+ metaData config.EgorMeta ,
62
+ noTimeOut bool ) (config.EgorMeta , error ) {
61
63
62
- output_file_name := case_name + ".ans"
63
- writeLinesToFile ("outputs/" + output_file_name , output_lines )
64
- output_file := config .NewIoFile (output_file_name , "outputs/" + output_file_name , true )
65
- meta_data .Outputs = append (meta_data .Outputs , output_file )
64
+ outputFileName := caseName + ".ans"
65
+ writeLinesToFile (path . Join ( "outputs" , outputFileName ), outputLines )
66
+ outputFile := config .NewIoFile (outputFileName , path . Join ( "outputs" , outputFileName ), true , noTimeOut )
67
+ metaData .Outputs = append (metaData .Outputs , outputFile )
66
68
67
- return meta_data , nil
69
+ return metaData , nil
68
70
}
69
71
70
72
// TODO(Eroui): add checks on errors
@@ -74,33 +76,47 @@ func CustomCaseAction(context *cli.Context) error {
74
76
// Load meta data
75
77
cwd , err := os .Getwd ()
76
78
if err != nil {
79
+ color .Red ("Failed to Generate Custom Case" )
77
80
return err
78
81
}
79
82
80
- meta_data , err := config .LoadMetaFromPath (path .Join (cwd , "egor-meta.json" ))
83
+ metaData , err := config .LoadMetaFromPath (path .Join (cwd , "egor-meta.json" ))
81
84
if err != nil {
85
+ color .Red ("Failed to load egor MetaData " )
82
86
return err
83
87
}
84
88
85
- case_name := "test-" + strconv .Itoa (len (meta_data .Inputs ))
89
+ noTimeOut := context .Bool ("no-timeout" )
90
+
91
+ caseName := "test-" + strconv .Itoa (len (metaData .Inputs ))
86
92
color .Green ("Provide your input:" )
87
- input_lines := readFromStdin ()
88
- meta_data , err = AddNewCaseInput (input_lines , case_name , meta_data )
93
+ inputLines := readFromStdin ()
94
+ metaData , err = AddNewCaseInput (inputLines , caseName , metaData , noTimeOut )
95
+
96
+ if err != nil {
97
+ color .Red ("Failed to add new case input" )
98
+ return err
99
+ }
89
100
90
101
if ! context .Bool ("no-output" ) {
91
102
color .Green ("Provide your output:" )
92
- output_lines := readFromStdin ()
93
- meta_data , err = AddNewCaseOutput (output_lines , case_name , meta_data )
103
+ outputLines := readFromStdin ()
104
+ metaData , err = AddNewCaseOutput (outputLines , caseName , metaData , noTimeOut )
105
+
106
+ if err != nil {
107
+ color .Red ("Failed to add new case output" )
108
+ return err
109
+ }
94
110
}
95
111
96
- meta_data .SaveToFile (path .Join (cwd , "egor-meta.json" ))
112
+ metaData .SaveToFile (path .Join (cwd , "egor-meta.json" ))
97
113
98
114
if err != nil {
99
- color .Red ("Failed to Generate Custom Case " )
115
+ color .Red ("Failed to save to MetaData " )
100
116
return err
101
117
}
102
118
103
- color .Green ("Created Custom Test Case... " )
119
+ color .Green ("Created Custom Test Case" )
104
120
return nil
105
121
}
106
122
@@ -116,5 +132,10 @@ var CaseCommand = cli.Command{
116
132
Usage : "This test case doesnt have output" ,
117
133
Value : false ,
118
134
},
135
+ & cli.BoolFlag {
136
+ Name : "no-timeout" ,
137
+ Usage : "This test case should not timeout when passed time limit" ,
138
+ Value : false ,
139
+ },
119
140
},
120
141
}
0 commit comments