Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tester
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
insert epic projlab name here
tester
Commits
bb658a9f
Verified
Commit
bb658a9f
authored
Apr 18, 2021
by
Tóth Miklós Tibor
Browse files
Options
Downloads
Patches
Plain Diff
moar test files plz
parent
7238d70d
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#7516
passed
Apr 19, 2021
Stage: build
Changes
2
Pipelines
3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+6
-1
6 additions, 1 deletion
.gitignore
src/main/java/tester/Main.java
+45
-31
45 additions, 31 deletions
src/main/java/tester/Main.java
with
51 additions
and
32 deletions
.gitignore
+
6
−
1
View file @
bb658a9f
...
@@ -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
This diff is collapsed.
Click to expand it.
src/main/java/tester/Main.java
+
45
−
31
View file @
bb658a9f
...
@@ -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"
,
ar
gs
[
0
]
));
proc
=
Runtime
.
getRuntime
().
exec
(
String
.
format
(
"java -jar %s --testing"
,
j
ar
file
));
}
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
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment