@@ -3105,7 +3105,7 @@ NORETURN void InStream::quit(TResult result, const char *msg) {
31053105 quits (_fail, __testlib_appendMessage (message, name));
31063106 }
31073107
3108- std::FILE *resultFile;
3108+ std::FILE *resultFile = stdout ;
31093109 std::string errorName;
31103110
31113111 if (__testlib_shouldCheckDirt (result)) {
@@ -3161,35 +3161,25 @@ NORETURN void InStream::quit(TResult result, const char *msg) {
31613161 resultName = " " ;
31623162 quit (_fail, " Can not write to the result file" );
31633163 }
3164- if (appesMode) {
3165- std::fprintf (resultFile, " <?xml version=\" 1.0\" encoding=\" %s\" ?>" , appesModeEncoding.c_str ());
3166- if (isPartial)
3167- std::fprintf (resultFile, " <result outcome = \" %s\" pctype = \" %d\" >" ,
3168- outcomes[(int ) _partially].c_str (), pctype);
3169- else {
3170- if (result != _points)
3171- std::fprintf (resultFile, " <result outcome = \" %s\" >" , outcomes[(int ) result].c_str ());
3172- else {
3173- if (__testlib_points == std::numeric_limits<float >::infinity ())
3174- quit (_fail, " Expected points, but infinity found" );
3175- std::string stringPoints = removeDoubleTrailingZeroes (testlib_format_ (" %.10f" , __testlib_points));
3176- std::fprintf (resultFile, " <result outcome = \" %s\" points = \" %s\" >" ,
3177- outcomes[(int ) result].c_str (), stringPoints.c_str ());
3178- }
3179- }
3180- xmlSafeWrite (resultFile, __testlib_toPrintableMessage (message).c_str ());
3181- std::fprintf (resultFile, " </result>\n " );
3182- } else
3183- std::fprintf (resultFile, " %s" , __testlib_toPrintableMessage (message).c_str ());
3184- if (NULL == resultFile || fclose (resultFile) != 0 ) {
3185- resultName = " " ;
3186- quit (_fail, " Can not write to the result file" );
3187- }
31883164 }
31893165
31903166 quitscr (LightGray, __testlib_toPrintableMessage (message).c_str ());
31913167 std::fprintf (stderr, " \n " );
31923168
3169+ if (result != _points)
3170+ std::fprintf (resultFile, " %d\n " , result == _ok ? 100 : 0 );
3171+ else {
3172+ if (__testlib_points == std::numeric_limits<float >::infinity ())
3173+ quit (_fail, " Expected points, but infinity found" );
3174+ std::string stringPoints = removeDoubleTrailingZeroes (format (" %.10f" , __testlib_points));
3175+ std::fprintf (resultFile, " %s\n " , stringPoints.c_str ());
3176+ }
3177+
3178+ if (resultName != " " && fclose (resultFile) != 0 ) {
3179+ resultName = " " ;
3180+ quit (_fail, " Can not write to the result file" );
3181+ }
3182+
31933183 inf.close ();
31943184 ouf.close ();
31953185 ans.close ();
@@ -3198,9 +3188,6 @@ NORETURN void InStream::quit(TResult result, const char *msg) {
31983188
31993189 textColor (LightGray);
32003190
3201- if (resultName != " " )
3202- std::fprintf (stderr, " See file to check exit message\n " );
3203-
32043191 halt (resultExitCode (result));
32053192}
32063193
@@ -3258,11 +3245,9 @@ void InStream::quitscrS(WORD color, std::string msg) {
32583245}
32593246
32603247void InStream::quitscr (WORD color, const char *msg) {
3261- if (resultName == " " ) {
3262- textColor (color);
3263- std::fprintf (stderr, " %s" , msg);
3264- textColor (LightGray);
3265- }
3248+ textColor (color);
3249+ std::fprintf (stderr, " %s" , msg);
3250+ textColor (LightGray);
32663251}
32673252
32683253void InStream::reset (std::FILE *file) {
@@ -4691,49 +4676,12 @@ void registerInteraction(int argc, char *argv[]) {
46914676 testlibMode = _interactor;
46924677 __testlib_set_binary (stdin);
46934678
4694- if (argc > 1 && !strcmp (" --help" , argv[1 ]))
4695- __testlib_help ();
4696-
4697- if (argc < 3 || argc > 6 ) {
4698- quit (_fail, std::string (" Program must be run with the following arguments: " ) +
4699- std::string (" <input-file> <output-file> [<answer-file> [<report-file> [<-appes>]]]" ) +
4700- " \n Use \" --help\" to get help information" );
4701- }
4702-
4703- if (argc <= 4 ) {
4704- resultName = " " ;
4705- appesMode = false ;
4706- }
4707-
4708- #ifndef EJUDGE
4709- if (argc == 5 ) {
4710- resultName = argv[4 ];
4711- appesMode = false ;
4712- }
4713-
4714- if (argc == 6 ) {
4715- if (strcmp (" -APPES" , argv[5 ]) && strcmp (" -appes" , argv[5 ])) {
4716- quit (_fail, std::string (" Program must be run with the following arguments: " ) +
4717- " <input-file> <output-file> <answer-file> [<report-file> [<-appes>]]" );
4718- } else {
4719- resultName = argv[4 ];
4720- appesMode = true ;
4721- }
4722- }
4723- #endif
4724-
4725- inf.init (argv[1 ], _input);
4726-
4727- tout.open (argv[2 ], std::ios_base::out);
4728- if (tout.fail () || !tout.is_open ())
4729- quit (_fail, std::string (" Can not write to the test-output-file '" ) + argv[2 ] + std::string (" '" ));
4730-
4679+ inf.init (" input" , _input);
47314680 ouf.init (stdin, _output);
4681+ ans.init (" answer" , _answer);
47324682
4733- if (argc >= 4 )
4734- ans.init (argv[3 ], _answer);
4735- else
4736- ans.name = " unopened answer stream" ;
4683+ resultName = " score.txt" ;
4684+ appesMode = false ;
47374685}
47384686
47394687void registerValidation () {
@@ -4868,57 +4816,13 @@ void registerTestlibCmd(int argc, char *argv[]) {
48684816 std::vector<std::string> args (1 , argv[0 ]);
48694817 checker.initialize ();
48704818
4871- for (int i = 1 ; i < argc; i++) {
4872- if (!strcmp (" --testset" , argv[i])) {
4873- if (i + 1 < argc && strlen (argv[i + 1 ]) > 0 )
4874- checker.setTestset (argv[++i]);
4875- else
4876- quit (_fail, std::string (" Expected testset after --testset command line parameter" ));
4877- } else if (!strcmp (" --group" , argv[i])) {
4878- if (i + 1 < argc)
4879- checker.setGroup (argv[++i]);
4880- else
4881- quit (_fail, std::string (" Expected group after --group command line parameter" ));
4882- } else
4883- args.push_back (argv[i]);
4884- }
4885-
4886- argc = int (args.size ());
4887- if (argc > 1 && " --help" == args[1 ])
4888- __testlib_help ();
4889-
4890- if (argc < 4 || argc > 6 ) {
4891- quit (_fail, std::string (" Program must be run with the following arguments: " ) +
4892- std::string (" [--testset testset] [--group group] <input-file> <output-file> <answer-file> [<report-file> [<-appes>]]" ) +
4893- " \n Use \" --help\" to get help information" );
4894- }
4895-
4896- if (argc == 4 ) {
4897- resultName = " " ;
4898- appesMode = false ;
4899- }
4900-
4901- #ifndef EJUDGE
4902- if (argc == 5 ) {
4903- resultName = args[4 ];
4904- appesMode = false ;
4905- }
4906-
4907- if (argc == 6 ) {
4908- if (" -APPES" != args[5 ] && " -appes" != args[5 ]) {
4909- quit (_fail, std::string (" Program must be run with the following arguments: " ) +
4910- " <input-file> <output-file> <answer-file> [<report-file> [<-appes>]]" );
4911- } else {
4912- resultName = args[4 ];
4913- appesMode = true ;
4914- }
4915- }
4916- #endif
4917-
4918- inf.init (args[1 ], _input);
4919- ouf.init (args[2 ], _output);
4819+ inf.init (" input" , _input);
4820+ ouf.init (" user_out" , _output);
49204821 ouf.skipBom ();
4921- ans.init (args[3 ], _answer);
4822+ ans.init (" answer" , _answer);
4823+
4824+ resultName = " " ;
4825+ appesMode = false ;
49224826}
49234827
49244828void registerTestlib (int argc, ...) {
0 commit comments