1- import { STATUS } from '@hydrooj/common' ;
1+ import { DetailType , STATUS } from '@hydrooj/common' ;
22import { FormatError , SystemError } from './error' ;
33import { CopyInFile , runQueued } from './sandbox' ;
44import { parse } from './testlib' ;
@@ -12,7 +12,7 @@ export interface CheckConfig {
1212 code : CopyInFile ;
1313 copyIn : Record < string , CopyInFile > ;
1414 score : number ;
15- detail : boolean ;
15+ detail : DetailType ;
1616 env ?: Record < string , string > ;
1717}
1818
@@ -85,7 +85,7 @@ elif [ -n "$result" ]; then
8585fi
8686` ;
8787
88- const getDefaultChecker = ( strict : boolean ) => async ( config ) => {
88+ const getDefaultChecker = ( strict : boolean ) => async ( config : CheckConfig ) => {
8989 const { code, stdout } = await runQueued ( `/bin/bash compare.sh${ strict ? '' : ' BZ' } ` , {
9090 copyIn : {
9191 usrout : config . user_stdout ,
@@ -102,7 +102,7 @@ const getDefaultChecker = (strict: boolean) => async (config) => {
102102 message = `Checker returned with status ${ code } ` ;
103103 } else if ( stdout ) {
104104 status = STATUS . STATUS_WRONG_ANSWER ;
105- if ( config . detail && ! strict ) message = parseDiffMsg ( stdout ) ;
105+ if ( config . detail === 'full' ) message = parseDiffMsg ( stdout ) ;
106106 } else status = STATUS . STATUS_ACCEPTED ;
107107 if ( message . length > 1024000 ) message = '' ;
108108 return {
@@ -135,7 +135,7 @@ const checkers: Record<string, Checker> = new Proxy({
135135 return {
136136 status,
137137 score : status === STATUS . STATUS_ACCEPTED ? config . score : 0 ,
138- message : stdout ,
138+ message : config . detail === 'full' ? stdout : '' ,
139139 } ;
140140 } ,
141141
@@ -168,7 +168,7 @@ const checkers: Record<string, Checker> = new Proxy({
168168 const score = Math . floor ( + files . score ) || 0 ;
169169 return {
170170 score,
171- message : files . message ,
171+ message : config . detail === 'full' ? files . message : '' ,
172172 status : score === config . score
173173 ? STATUS . STATUS_ACCEPTED
174174 : STATUS . STATUS_WRONG_ANSWER ,
@@ -193,7 +193,7 @@ const checkers: Record<string, Checker> = new Proxy({
193193 return {
194194 status : st ,
195195 score : ( status === STATUS . STATUS_ACCEPTED ) ? config . score : 0 ,
196- message : stdout ,
196+ message : config . detail === 'full' ? stdout : '' ,
197197 } ;
198198 } ,
199199
@@ -219,7 +219,7 @@ const checkers: Record<string, Checker> = new Proxy({
219219 if ( status !== STATUS . STATUS_ACCEPTED ) throw new SystemError ( 'Checker returned {0}.' , [ status ] ) ;
220220 const score = + stdout ;
221221 status = score === 100 ? STATUS . STATUS_ACCEPTED : STATUS . STATUS_WRONG_ANSWER ;
222- return { status, score : Math . floor ( ( score * config . score ) / 100 ) , message : stderr } ;
222+ return { status, score : Math . floor ( ( score * config . score ) / 100 ) , message : config . detail === 'full' ? stderr : '' } ;
223223 } ,
224224
225225 async testlib ( config ) {
@@ -252,7 +252,7 @@ const checkers: Record<string, Checker> = new Proxy({
252252 message : `Checker exited with code ${ code } ` ,
253253 } ;
254254 }
255- return parse ( stderr , config . score ) ;
255+ return parse ( stderr , config . score , config . detail ) ;
256256 } ,
257257
258258 // https://www.kattis.com/problem-package-format/spec/2023-07-draft.html#output-validator
@@ -285,7 +285,9 @@ const checkers: Record<string, Checker> = new Proxy({
285285
286286 const message = status === STATUS . STATUS_SYSTEM_ERROR
287287 ? files [ 'feedback_dir/judgeerror.txt' ] || `Checker exited with code ${ code } `
288- : files [ 'feedback_dir/teammessage.txt' ] || files [ 'feedback_dir/judgemessage.txt' ] || '' ;
288+ : config . detail === 'full'
289+ ? files [ 'feedback_dir/teammessage.txt' ] || files [ 'feedback_dir/judgemessage.txt' ] || ''
290+ : '' ;
289291
290292 return { status, score, message } ;
291293 } ,
0 commit comments