Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. commit d072df55c71ed2272af2f3daf6a9e8667777fde0
  2. Author: Marcelo Fornet <mfornet94@gmail.com>
  3. Date: Sun Oct 20 22:19:04 2019 -0500
  4.  
  5. Allow solutions to run in windows.
  6.  
  7. Warn about 0 testcases.
  8.  
  9. diff --git a/src/core.ts b/src/core.ts
  10. index 2b77d85..d2f675c 100644
  11. --- a/src/core.ts
  12. +++ b/src/core.ts
  13. @@ -350,7 +350,7 @@ export function timedRun(path: string, tcName: string, timeout: number){
  14. closeSync(inputFd);
  15.  
  16. let startTime = new Date().getTime();
  17. - let command = `${join(path, ATTIC, "sol")}`;
  18. + let command = `${join(path, ATTIC, "sol.exe")}`;
  19.  
  20. let xresult = child_process.spawnSync(command, {
  21. input: tcData,
  22. @@ -449,7 +449,7 @@ export function compileCode(pathCode: string, pathOutput: string){
  23.  
  24. export function testSolution(path: string){
  25. let sol = join(path, solFile());
  26. - let out = join(path, ATTIC, 'sol');
  27. + let out = join(path, ATTIC, 'sol.exe');
  28.  
  29. if (!existsSync(sol)){
  30. throw new Error("Open a coding environment first.");
  31. @@ -463,6 +463,11 @@ export function testSolution(path: string){
  32. }
  33.  
  34. let testcasesId = testcasesName(path);
  35. +
  36. + if (testcasesId.length === 0){
  37. + return new SolutionResult(Veredict.NO_TESTCASES, undefined, undefined);
  38. + }
  39. +
  40. // Proccess all testcases in sorted order
  41. testcasesId.sort();
  42.  
  43. @@ -477,16 +482,13 @@ export function testSolution(path: string){
  44.  
  45. let results: TestcaseResult[] = [];
  46. let fail: SolutionResult | undefined = undefined;
  47. -
  48. testcasesId.forEach(tcId => {
  49. // Run while there none have failed already
  50. if (fail === undefined){
  51. let tcResult = timedRun(path, tcId, getTimeout());
  52. -
  53. if (tcResult.status !== Veredict.OK){
  54. fail = new SolutionResult(tcResult.status, tcId);
  55. }
  56. -
  57. results.push(tcResult);
  58. }
  59. });
  60. diff --git a/src/extension.ts b/src/extension.ts
  61. index f663028..efe9e10 100644
  62. --- a/src/extension.ts
  63. +++ b/src/extension.ts
  64. @@ -129,6 +129,9 @@ async function runSolution(){
  65. if (result.status === Veredict.OK){
  66. vscode.window.showInformationMessage(`OK. Time ${result.maxTime!}ms`);
  67. }
  68. + else if (result.status === Veredict.NO_TESTCASES){
  69. + vscode.window.showErrorMessage(`No testcases.`);
  70. + }
  71. else{
  72. vscode.window.showErrorMessage(`${veredictName(result.status)} on test ${result.failTcId}`);
  73. debugTestcase(path, result.failTcId!);
  74. diff --git a/src/types.ts b/src/types.ts
  75. index 595ac22..209b4aa 100644
  76. --- a/src/types.ts
  77. +++ b/src/types.ts
  78. @@ -4,6 +4,7 @@ export enum Veredict{
  79. TLE, // Time Limit Exceeded
  80. RTE, // Runtime Error
  81. CE, // Compilation Error
  82. + NO_TESTCASES,
  83. }
  84.  
  85. export class TestcaseResult{
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement