Add assert message for multiple lines in osprobe (#60796)

Several /proc files are expected to contain a single line. We assert on
this in tests, but the contents of the file are lost and the assertion
therefore lacks important information to debug why the file appeared to
have multiple lines. This commit dumps the contents of the file on
assertion failure.

relates #59284
This commit is contained in:
Ryan Ernst 2020-08-06 15:53:11 -07:00 committed by Ryan Ernst
parent 479f32906d
commit ddcfbec569
No known key found for this signature in database
GPG Key ID: 5F7EA39E15F54DCE
1 changed files with 1 additions and 1 deletions

View File

@ -233,7 +233,7 @@ public class OsProbe {
*/ */
private String readSingleLine(final Path path) throws IOException { private String readSingleLine(final Path path) throws IOException {
final List<String> lines = Files.readAllLines(path); final List<String> lines = Files.readAllLines(path);
assert lines != null && lines.size() == 1; assert lines.size() == 1 : String.join("\n", lines);
return lines.get(0); return lines.get(0);
} }