-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from AsherGlick/proto_integration_tests
Adding Proto Tests
- Loading branch information
Showing
16 changed files
with
174 additions
and
63 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
xml_converter/intigration_tests/expected_outputs/proto_can_fade_invalid/markers.bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
" | ||
My Category 2B\�)Cf�RC{�WC | ||
|
3 changes: 3 additions & 0 deletions
3
xml_converter/intigration_tests/expected_outputs/proto_can_fade_valid/markers.bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
7 | ||
My Category 2B\�)Cf�RC{�WC 2B\�)Cf�RC{�WC | ||
|
3 changes: 3 additions & 0 deletions
3
xml_converter/intigration_tests/expected_outputs/proto_mount_filter_invalid/markers.bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
o | ||
My Category 2B\�)Cf�RC{�WC 2B\�)Cf�RC{�WC 2B\�)Cf�RC{�WC� 2B\�)Cf�RC{�WC� | ||
|
3 changes: 3 additions & 0 deletions
3
xml_converter/intigration_tests/expected_outputs/proto_mount_filter_valid/markers.bin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
� | ||
My Category 2B\�)Cf�RC{�WC� 2B\�)Cf�RC{�WC� 2B\�)Cf�RC{�WC�* 2B\�)Cf�RC{�WC� (08@HP | ||
|
4 changes: 2 additions & 2 deletions
4
xml_converter/intigration_tests/expected_outputs/xml_can_fade_invalid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
</POIs> | ||
</OverlayData> |
6 changes: 3 additions & 3 deletions
6
xml_converter/intigration_tests/expected_outputs/xml_can_fade_valid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="false" Type="mycategory" IconFile="texture.png" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI CanFade="false" Type="mycategory" IconFile="texture.png" MapID="50" XPos="179.809998" YPos="220.649994" ZPos="225.830002"/> | ||
<POI CanFade="false" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI CanFade="false" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
</POIs> | ||
</OverlayData> |
10 changes: 5 additions & 5 deletions
10
xml_converter/intigration_tests/expected_outputs/xml_mount_filter_invalid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
</POIs> | ||
</OverlayData> |
10 changes: 5 additions & 5 deletions
10
xml_converter/intigration_tests/expected_outputs/xml_mount_filter_valid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" IconFile="texture.png" MapID="50" Mount="raptor,springer,skimmer,jackal,griffon,rollerbeetle,warclaw,skyscale,skiff,seigeturtle" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor,springer" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
<POI Type="mycategory" MapID="50" Mount="raptor,springer,skimmer,jackal,griffon,rollerbeetle,warclaw,skyscale,skiff,seigeturtle" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/> | ||
</POIs> | ||
</OverlayData> |
10 changes: 5 additions & 5 deletions
10
xml_converter/intigration_tests/inputs/xml_can_fade_invalid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
</MarkerCategory> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="yes" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" /> | ||
</POIs> | ||
<POIs> | ||
<POI CanFade="yes" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
</POIs> | ||
</OverlayData> |
20 changes: 10 additions & 10 deletions
20
xml_converter/intigration_tests/inputs/xml_can_fade_valid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
</MarkerCategory> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI CanFade="false" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" /> | ||
<POI CanFade="0" Type="mycategory" XPos="179.81" YPos="220.65" ZPos="225.83" MapID="50" IconFile="texture.png" /> | ||
<!-- TODO: This value should be elided in the output, but it is not currently | ||
so we are ignoring the test instead of wriitng a bad test | ||
<POI CanFade="true" Type="mycategory"/> | ||
<POI CanFade="1" Type="mycategory"/> --> | ||
</POIs> | ||
<POIs> | ||
<POI CanFade="false" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI CanFade="0" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<!-- TODO: This value should be elided in the output, but it is not currently | ||
so we are ignoring the test instead of wriitng a bad test | ||
<POI CanFade="true" Type="mycategory"/> | ||
<POI CanFade="1" Type="mycategory"/> --> | ||
</POIs> | ||
</OverlayData> |
16 changes: 8 additions & 8 deletions
16
xml_converter/intigration_tests/inputs/xml_mount_filter_invalid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
</MarkerCategory> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI Mount="" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="NotAMount" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="Raptor,Springer," Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="Raptor,NotAMount,Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
</POIs> | ||
<POIs> | ||
<POI Mount="" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="NotAMount" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="Raptor,Springer," Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="Raptor,NotAMount,Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
</POIs> | ||
</OverlayData> |
16 changes: 8 additions & 8 deletions
16
xml_converter/intigration_tests/inputs/xml_mount_filter_valid/xml_file.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<OverlayData> | ||
<MarkerCategory Name="mycategory"> | ||
</MarkerCategory> | ||
<MarkerCategory DisplayName="My Category" Name="mycategory"> | ||
</MarkerCategory> | ||
|
||
<POIs> | ||
<POI Mount="Raptor" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="Raptor,Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="Raptor, Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
<POI Mount="Raptor,Springer,Skimmer,Jackal,Griffon,RollerBeetle,Warclaw,Skyscale,Skiff,SeigeTurtle" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" IconFile="texture.png" Type="mycategory"/> | ||
</POIs> | ||
<POIs> | ||
<POI Mount="Raptor" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="Raptor,Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="Raptor, Springer" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
<POI Mount="Raptor,Springer,Skimmer,Jackal,Griffon,RollerBeetle,Warclaw,Skyscale,Skiff,SeigeTurtle" Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" /> | ||
</POIs> | ||
</OverlayData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import os | ||
import subprocess | ||
import difflib | ||
|
||
def compare_protos( | ||
outputs_directory: str, | ||
expected_outputs_directory: str, | ||
) -> bool: | ||
# TODO: These paths are directories and 'markers.bin` is just one | ||
# possible file in the directories. Eventually we should check all | ||
# the files in the directory not just the one. | ||
files_are_equal = compare_binary_file( | ||
os.path.join(expected_outputs_directory, "markers.bin"), | ||
os.path.join(outputs_directory, "markers.bin"), | ||
) | ||
|
||
if files_are_equal: | ||
return True | ||
|
||
expected_textproto_path = os.path.join(expected_outputs_directory, "markers.bin") | ||
actual_textproto_path = os.path.join(outputs_directory, "markers.bin") | ||
|
||
expected_textproto = get_waypoint_textproto(expected_textproto_path) | ||
actual_textproto = get_waypoint_textproto(actual_textproto_path) | ||
|
||
diff = difflib.unified_diff(expected_textproto.split("\n"), actual_textproto.split("\n"), fromfile=expected_textproto_path, tofile=actual_textproto_path, lineterm="") | ||
|
||
for line in diff: | ||
print(line) | ||
|
||
# TODO: Also might be good to include a HEX diff breakdown because if the | ||
# diff is just ordering then the textproto conversion might correct the | ||
# error and make it look like there is no diff but the test still fails. | ||
|
||
return False | ||
|
||
def compare_binary_file(file_path_1: str, file_path_2: str) -> bool: | ||
if not os.path.exists(file_path_1): | ||
return False | ||
if not os.path.exists(file_path_2): | ||
return False | ||
|
||
with open(file_path_1, 'rb') as file1: | ||
contents_1 = file1.read() | ||
with open(file_path_2, 'rb') as file2: | ||
contents_2 = file2.read() | ||
|
||
return contents_1 == contents_2 | ||
|
||
|
||
################################################################################ | ||
# get_waypoint_textproto | ||
# | ||
# Reads a waypoint protobin and returns a stringy textproto value of the | ||
# contents of the protobin. This makes it easier to diff the contents but also | ||
# can be used to easily inspect the values of the protobin. | ||
################################################################################ | ||
def get_waypoint_textproto(protobin_path: str) -> str: | ||
proto_schema_path = "../proto/waypoint.proto" | ||
proto_schema_basedir = "../proto" | ||
|
||
if not os.path.exists(protobin_path): | ||
return "" | ||
|
||
with open(protobin_path, 'rb') as f: | ||
result = subprocess.run( | ||
[ | ||
"protoc", | ||
"--decode=waypoint.Waypoint", | ||
"--proto_path=" + proto_schema_basedir, | ||
proto_schema_path | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
stdin=f, | ||
) | ||
|
||
# TODO: sanity check return code, stdout, and stderr | ||
|
||
return result.stdout.decode("utf-8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters