Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Hedtke, Moritz
AuD 2021 H05 Tests
Commits
e277b3ed
Verified
Commit
e277b3ed
authored
Jun 12, 2021
by
Daniel Mangold
Browse files
Minor changes to Utils.java
parent
e6b0d026
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/h05/Utils.java
View file @
e277b3ed
...
...
@@ -38,12 +38,12 @@ public class Utils {
if
(!(
Boolean
)
getConfigOrDefault
(
"EXISTS"
,
false
))
System
.
err
.
println
(
"Configurations could not be found, they must be downloaded from the repository. "
+
"They will be automatically downloaded when using the installer or when CHECK_FOR_UPDATES and AUTO_UPDATE are true. "
+
"Please re-run the tests."
);
"Please re-run the tests
afterwards
."
);
if
(
CHECK_FOR_UPDATES
)
Updater
.
checkForUpdates
(
);
System
.
out
.
println
(
"
Seed: "
+
SEED
);
if
(
!
CHECK_FOR_UPDATES
||
!
Updater
.
checkForUpdates
()
)
System
.
out
.
println
(
"Seed: "
+
SEED
);
else
System
.
out
.
println
(
"
Updated tests, please re-run"
);
}
/**
...
...
@@ -203,16 +203,18 @@ public class Utils {
* </ul>
*
* Messages are printed in any case to let the user know what is happening
* @return whether any changes have been written
*/
private
static
void
checkForUpdates
()
{
private
static
boolean
checkForUpdates
()
{
HttpResponse
<
String
>
response
=
getHttpResource
(
".test_version"
);
if
(
response
==
null
||
response
.
statusCode
()
!=
200
)
{
System
.
err
.
println
(
"Unable to fetch version from repository"
);
return
;
return
false
;
}
try
(
BufferedReader
remoteReader
=
new
BufferedReader
(
new
StringReader
(
response
.
body
())))
{
boolean
persistentChanges
=
false
;
String
[]
versionLine
=
remoteReader
.
readLine
().
split
(
" -- "
,
2
);
Version
localVersion
=
new
Version
(
LOCAL_VERSION
),
remoteVersion
=
new
Version
(
versionLine
[
0
]);
...
...
@@ -221,8 +223,7 @@ public class Utils {
System
.
out
.
println
(
"Update available! Local version: "
+
localVersion
+
" -- Remote version: "
+
remoteVersion
);
System
.
out
.
println
(
"Changelog: "
+
REPOSITORY_URL
+
"blob/master/changelog.md"
);
System
.
out
.
println
(
versionLine
[
1
]);
}
else
System
.
out
.
println
(
"Local tests are up to date"
);
}
for
(
String
line
=
remoteReader
.
readLine
();
...
...
@@ -238,9 +239,11 @@ public class Utils {
File
file
=
new
File
(
fileName
);
if
(!
file
.
exists
())
{
if
(
AUTO_UPDATE
)
if
(
AUTO_UPDATE
)
{
updateLocal
(
fileName
);
else
persistentChanges
=
true
;
}
else
System
.
err
.
println
(
fileName
+
" not found, can't compare hashes"
);
continue
;
...
...
@@ -254,15 +257,23 @@ public class Utils {
if
(!
actualHash
.
equals
(
expectedHash
))
{
System
.
out
.
println
(
"Hash mismatch for file "
+
fileName
);
if
(
AUTO_UPDATE
)
if
(
AUTO_UPDATE
)
{
updateLocal
(
fileName
);
persistentChanges
=
true
;
}
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
System
.
out
.
println
(
"Local tests are up to date"
);
return
persistentChanges
;
}
catch
(
IOException
|
InterruptedException
|
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
true
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment