Skip to content
Snippets Groups Projects
Verified Commit bb658a9f authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

moar test files plz

parent 7238d70d
Branches
No related tags found
No related merge requests found
Pipeline #7516 passed
...@@ -102,5 +102,10 @@ build ...@@ -102,5 +102,10 @@ build
build/* build/*
test.json test.json
test1.json
test2.json
oof oof
hello.jar hello.jar
comm.puml
seq.puml
kiskacsa.exe
...@@ -5,7 +5,6 @@ import com.google.gson.Gson; ...@@ -5,7 +5,6 @@ import com.google.gson.Gson;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -24,38 +23,24 @@ public class Main { ...@@ -24,38 +23,24 @@ public class Main {
return sb.toString(); return sb.toString();
} }
public static void main(String[] args) throws FileNotFoundException { private static boolean runTest(String jarfile, String testName) throws FileNotFoundException {
if (args.length < 2) { System.out.printf("Running test \"%s\"\n", testName);
System.out.println("usage: <tested_app.jar> <testcase.json>");
System.exit(1);
}
Gson gson = new Gson(); Gson gson = new Gson();
TestCase test = gson.fromJson(new FileReader(args[1]), TestCase.class); TestCase test = gson.fromJson(new FileReader(testName), TestCase.class);
test.input = yeetEmpty(test.input); test.input = yeetEmpty(test.input);
test.output = yeetEmpty(test.output); test.output = yeetEmpty(test.output);
if (System.getProperty("os.name").toLowerCase().contains("win")){
try {
ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "@chcp", "65001>nul").inheritIO();
Process p = pb.start();
p.waitFor();
System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
} catch (Exception e) {
e.printStackTrace();
}
}
Process proc; Process proc;
try { try {
proc = Runtime.getRuntime().exec(String.format("java -jar %s --testing", args[0])); proc = Runtime.getRuntime().exec(String.format("java -jar %s --testing", jarfile));
} catch (Exception e) { } catch (Exception e) {
System.out.print("❌ "); System.out.print("❌ ");
System.out.printf("Nem sikerület elindítani a folyamatot, kérlek ellenőrizd, hogy tesztelendő program tényleg itt van-e: \"%s\"\n", args[0]); System.out.printf("Nem sikerület elindítani a folyamatot, kérlek ellenőrizd, hogy tesztelendő program tényleg itt van-e: \"%s\"\n", jarfile);
System.exit(1); return false;
return;
} }
var in = proc.getOutputStream(); var in = proc.getOutputStream();
...@@ -68,8 +53,7 @@ public class Main { ...@@ -68,8 +53,7 @@ public class Main {
} catch (Exception e) { } catch (Exception e) {
System.out.print("❌ "); System.out.print("❌ ");
System.out.println("A program nem fogadott annyi inputot, amennyi meg volt adva."); System.out.println("A program nem fogadott annyi inputot, amennyi meg volt adva.");
System.exit(1); return false;
return;
} }
try { try {
...@@ -77,8 +61,7 @@ public class Main { ...@@ -77,8 +61,7 @@ public class Main {
} catch (Exception e) { } catch (Exception e) {
System.out.print("❌ "); System.out.print("❌ ");
System.out.println("Nem sikerült a programnak helyesen bezáródni."); System.out.println("Nem sikerült a programnak helyesen bezáródni.");
System.exit(1); return false;
return;
} }
String o = ""; String o = "";
...@@ -141,7 +124,38 @@ public class Main { ...@@ -141,7 +124,38 @@ public class Main {
} }
System.out.println(" végződött."); System.out.println(" végződött.");
if (error.get()) { System.out.println("==============");
System.out.println();
return !error.get();
}
public static void main(String[] args) throws FileNotFoundException {
if (args.length < 2) {
System.out.println("usage: <tested_app.jar> <testcase.json> [testcase.json...]");
System.exit(1);
}
if (System.getProperty("os.name").toLowerCase().contains("win")){
try {
ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "@chcp", "65001>nul").inheritIO();
Process p = pb.start();
p.waitFor();
System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
} catch (Exception e) {
e.printStackTrace();
}
}
var everythingIsFine = true;
var jar = args[0];
for (int i = 1; i < args.length; i++) {
if (!runTest(jar, args[i])) {
everythingIsFine = false;
}
}
if (!everythingIsFine) {
System.exit(1); System.exit(1);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment