Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/Utils/TestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ public function create(Build $build): void
$this->testOutput = gzuncompress($this->testOutput);
}

if (mb_detect_encoding($this->testOutput, 'UTF-8', true) === false) {
$this->testOutput = mb_convert_encoding($this->testOutput, 'UTF-8', 'UTF-8');
if ($this->testOutput === false) {
Log::error("Unable to encode {$this->testName} output as UTF-8");
$this->testOutput = '';
}
}

DB::insert(
'INSERT INTO testoutput (path, command, output, crc32)
VALUES (:path, :command, :output, :crc32)',
Expand Down
78 changes: 54 additions & 24 deletions tests/Feature/Submission/Tests/TestXMLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ protected function tearDown(): void
}

/**
* Test parsing valid Test.xml file(s).
* Test parsing a valid Test.xml file that contains angle brackets
* in the test name.
*/
public function testValidXML(): void
public function testAngleBracketsInName(): void
{
$this->submitFiles($this->project->name, [
base_path(
Expand All @@ -47,41 +48,70 @@ public function testValidXML(): void
]);

$this->graphQL('
query project($id: ID) {
project(id: $id) {
builds {
query build($id: ID) {
build(id: $id) {
tests {
edges {
node {
tests {
edges {
node {
name
}
}
}
name
}
}
}
}
}
', [
'id' => $this->project->id,
'id' => $this->project->builds()->firstOrFail()->id,
])->assertExactJson([
'data' => [
'project' => [
'builds' => [
'build' => [
'tests' => [
'edges' => [
[
'node' => [
'tests' => [
'edges' => [
[
'node' => [
'name' => 'MyTest<parameterized>',
],
],
],
],
'name' => 'MyTest<parameterized>',
],
],
],
],
],
],
]);
}

/**
* Test parsing a valid Test.xml file that contains non-UTF-8 characters
* in the test output.
*/
public function testNonUTF8Output(): void
{
$this->submitFiles($this->project->name, [
base_path(
'tests/Feature/Submission/Tests/data/non_utf8_output.xml'
),
]);

$this->graphQL('
query build($id: ID) {
build(id: $id) {
tests {
edges {
node {
name
}
}
}
}
}
', [
'id' => $this->project->builds()->firstOrFail()->id,
])->assertExactJson([
'data' => [
'build' => [
'tests' => [
'edges' => [
[
'node' => [
'name' => 'NonUtf8Output',
],
],
],
Expand Down
39 changes: 39 additions & 0 deletions tests/Feature/Submission/Tests/data/non_utf8_output.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Site BuildName="dummy_test_name"
BuildStamp="dummy_stamp"
Name="dummy_name"
>
<Testing>
<StartDateTime>Jul 07 11:17 EDT</StartDateTime>
<StartTestTime>1751901433</StartTestTime>
<TestList>
<Test>./NonUtf8Output</Test>
</TestList>
<Test Status="passed">
<Name>NonUtf8Output</Name>
<Path>.</Path>
<FullName>./NonUtf8Output</FullName>
<FullCommandLine>/tmp/bin/mytest</FullCommandLine>
<Results>
<NamedMeasurement type="numeric/double" name="Execution Time">
<Value>0.1</Value>
</NamedMeasurement>
<NamedMeasurement type="numeric/double" name="Processors">
<Value>1</Value>
</NamedMeasurement>
<NamedMeasurement type="text/string" name="Completion Status">
<Value>Completed</Value>
</NamedMeasurement>
<NamedMeasurement type="text/string" name="Command Line">
<Value>/tmp/bin/mytest</Value>
</NamedMeasurement>
<Measurement>
<Value encoding="base64" compression="gzip">eJyVkstOhDAYhfd9in+pCwiU2zDvoCt3xhiEX2kiLWkLM670zXXACb3IXNyR03NOvp4ycMXeODZQt5W86Ri/BVnttkCgFnxEqbHZQkQGx3YveC8U02zEu7WE7++q/dH0bdfSLPOMUgy8eUYphVzn8Ci/7NMgphtyms/yGqch+7SrYlqQ64AWftUKqS206KxvlTBaXfBYvIDmWZZkdvks+P6/4B6QzxsktMg3zp6zQs4A+xknYYgntbCbZ4FcCbpcjPFr9p1c/1h3Ll1IU1qmZV7Q0hnYqG7uIrpLHNA4LdJNkqfuzEYmJ+FXs37S3GM5cGY3KlnwwzAkjw8tU9BXUoN4Bd0iaFSH70H3g4ZdpUBiJ8bp32K8RmAacF8jNurX3Eo8vOV7M6XjiKbw8nEoCJ/ID/+ycio=</Value>
</Measurement>
</Results>
</Test>
<EndDateTime>Jul 07 11:17 EDT</EndDateTime>
<EndTestTime>1751901433</EndTestTime>
<ElapsedMinutes>0</ElapsedMinutes>
</Testing>
</Site>