Fix Update Golden With DiffDir

Change-Id: I30c79a2acaae2d3066982d84776aaa922e183515
This commit is contained in:
Aaron Vaage 2018-02-26 12:12:59 -08:00
parent 387fe8e33b
commit 9547000eb6
3 changed files with 11 additions and 22 deletions

View File

@ -353,6 +353,9 @@ class PackagerAppTest(unittest.TestCase):
out_dir = self.tmp_dir out_dir = self.tmp_dir
gold_dir = os.path.join(self.golden_file_dir, test_dir) gold_dir = os.path.join(self.golden_file_dir, test_dir)
if not os.path.exists(gold_dir):
os.makedirs(gold_dir)
# Get a list of the files and dirs that are different between the two top # Get a list of the files and dirs that are different between the two top
# level directories. # level directories.
diff = filecmp.dircmp(out_dir, gold_dir) diff = filecmp.dircmp(out_dir, gold_dir)
@ -360,17 +363,17 @@ class PackagerAppTest(unittest.TestCase):
# Files in the output that are not in the gold dir yet, need to be copied # Files in the output that are not in the gold dir yet, need to be copied
# over. # over.
for filename in diff.left_only: for filename in diff.left_only:
out_path = os.path.join(out_dir, filename) shutil.copyfile(
shutil.copyfile(out_path, gold_dir) os.path.join(out_dir, filename),
os.path.join(gold_dir, filename))
# Files in the gold dir but not in the output need to be removed. # Files in the gold dir but not in the output need to be removed.
for filename in diff.right_only: for filename in diff.right_only:
gold_path = os.path.join(gold_dir, filename) os.rm(os.path.join(gold_dir, filename))
os.rm(gold_path)
# Copy any changed files over to the gold directory. # Copy any changed files over to the gold directory.
for filename in diff.diff_files: for filename in diff.diff_files:
out_path = os.path.join(out_dir, filename) shutil.copyfile(
gold_path = os.path.join(gold_dir, filename) os.path.join(out_dir, filename),
shutil.copyfile(out_path, gold_path) os.path.join(gold_dir, filename))
# |test_dir| is expected to be relative to |self.golden_file_dir|. # |test_dir| is expected to be relative to |self.golden_file_dir|.
def _DiffDir(self, test_dir): def _DiffDir(self, test_dir):
@ -1378,7 +1381,7 @@ class PackagerFunctionalTest(PackagerAppTest):
flags = self._GetFlags(output_hls=True) flags = self._GetFlags(output_hls=True)
self.assertPackageSuccess(streams, flags) self.assertPackageSuccess(streams, flags)
self._DiffDir('hls-segmented-webvtt') self._CheckTestResults('hls-segmented-webvtt')
def _AssertStreamInfo(self, stream, info): def _AssertStreamInfo(self, stream, info):
stream_info = self.packager.DumpStreamInfo(stream) stream_info = self.packager.DumpStreamInfo(stream)

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.73607S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_0.mp4</BaseURL>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>