From f5510758493ff498bb86d7c782d4de3088ce5931 Mon Sep 17 00:00:00 2001 From: Jae Woong Date: Tue, 9 Dec 2025 10:16:05 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20Kotlin=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EC=8B=9C=20=EC=B6=9C=EB=A0=A5=EC=9D=B4=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컴파일 프로세스 대신 실행 프로세스를 반환하도록 수정 - execSync로 컴파일을 동기적으로 완료 후 java 프로세스 반환 - C/C++/Rust와 동일한 compileAndRun 패턴 적용 --- src/utils/testCaseRunner.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/utils/testCaseRunner.ts b/src/utils/testCaseRunner.ts index 9e0015a..44da550 100644 --- a/src/utils/testCaseRunner.ts +++ b/src/utils/testCaseRunner.ts @@ -165,9 +165,7 @@ function getProcessForRunning(filePath: string) { case 'rs': return compileAndRunRust(filePath); case 'kt': - return childProcess.spawn('kotlinc', [filePath, '-include-runtime', '-d', 'Program.jar']) - .on('close', () => childProcess.spawn('java', ['-jar', 'Program.jar'])); - + return compileAndRunKotlin(filePath); case 'swift': return childProcess.spawn('swift', [filePath]); @@ -192,6 +190,26 @@ function compileAndRunC(filePath: string) { return compileAndRun(filePath, 'gcc'); } +function compileAndRunKotlin(filePath: string) { + const fileDir = path.dirname(filePath); + const jarFile = path.join(fileDir, 'Program.jar'); + + const config = vscode.workspace.getConfiguration('BOJ-Tester'); + const customOptions = config.get<{ [key: string]: string }>('customCommandOption', {}); + + let compileCommand: string; + if (customOptions['kt']) { + const options = customOptions['kt'].split(' '); + compileCommand = `kotlinc ${options.join(' ')} "${filePath}" -include-runtime -d "${jarFile}"`; + } else { + compileCommand = `kotlinc "${filePath}" -include-runtime -d "${jarFile}"`; + } + + execSync(compileCommand); + return childProcess.spawn('java', ['-jar', jarFile]) + .on('close', () => childProcess.spawn(process.platform === 'win32' ? 'del' : 'rm', [jarFile])); +} + function compileAndRun(filePath: string, compiler: 'gcc' | 'g++' | 'rustc') { const extension = filePath.split('.').pop()?.toLowerCase() as string; const outputFile = filePath.replace(/\.(c|cpp|rs)$/, '');