Updated Nested Directories Test

This require a change to the update gold method as it would not
create nested directories. Instead it deletes the old directory
and copies the whole new directory over. This made the code simplier
and far-less error prone.

Change-Id: I1da5d9bda171b0f106d1425b204139dfbcb39b42
This commit is contained in:
Aaron Vaage 2018-03-01 10:48:10 -08:00
parent 4ace2754fd
commit 74c53239dd
12 changed files with 6 additions and 30 deletions

View File

@ -411,27 +411,10 @@ 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): if os.path.exists(gold_dir):
os.makedirs(gold_dir) shutil.rmtree(gold_dir)
# Get a list of the files and dirs that are different between the two top shutil.copytree(out_dir, gold_dir)
# level directories.
diff = filecmp.dircmp(out_dir, gold_dir)
# Files in the output that are not in the gold dir yet, need to be copied
# over.
for file_name in diff.left_only:
shutil.copyfile(
os.path.join(out_dir, file_name),
os.path.join(gold_dir, file_name))
# Files in the gold dir but not in the output need to be removed.
for file_name in diff.right_only:
os.remove(os.path.join(gold_dir, file_name))
# Copy any changed files over to the gold directory.
for file_name in diff.diff_files:
shutil.copyfile(
os.path.join(out_dir, file_name),
os.path.join(gold_dir, file_name))
# |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):
@ -1158,6 +1141,7 @@ class PackagerFunctionalTest(PackagerAppTest):
audio_output_prefix = os.path.join(self.tmp_dir, 'audio', 'audio') audio_output_prefix = os.path.join(self.tmp_dir, 'audio', 'audio')
# {tmp}/video/video-init.mp4, {tmp}/video/video-1.m4s etc. # {tmp}/video/video-init.mp4, {tmp}/video/video-1.m4s etc.
video_output_prefix = os.path.join(self.tmp_dir, 'video', 'video') video_output_prefix = os.path.join(self.tmp_dir, 'video', 'video')
self.assertPackageSuccess( self.assertPackageSuccess(
[ [
'input=%s,stream=audio,init_segment=%s-init.mp4,' 'input=%s,stream=audio,init_segment=%s-init.mp4,'
@ -1168,16 +1152,8 @@ class PackagerFunctionalTest(PackagerAppTest):
(test_file, video_output_prefix, video_output_prefix), (test_file, video_output_prefix, video_output_prefix),
], ],
self._GetFlags(output_hls=True)) self._GetFlags(output_hls=True))
self._DiffLiveGold(audio_output_prefix, 'bear-640x360-a-live-golden')
self._DiffLiveGold(video_output_prefix, 'bear-640x360-v-live-golden') self._CheckTestResults('hls-multi-segment-mp4-with-custom-path')
self._DiffGold(self.hls_master_playlist_output,
'bear-640x360-av-mp4-master-golden.m3u8')
self._DiffGold(
os.path.join(self.tmp_dir, 'audio', 'audio.m3u8'),
'bear-640x360-a-mp4-golden.m3u8')
self._DiffGold(
os.path.join(self.tmp_dir, 'video', 'video.m3u8'),
'bear-640x360-v-mp4-golden.m3u8')
def testPackageLiveProfile(self): def testPackageLiveProfile(self):
self.assertPackageSuccess( self.assertPackageSuccess(