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)$/, '');