Skip to content

Commit 2f27005

Browse files
author
Stewart Miles
committed
Disable use of tar command in test on macOS.
tar / gzip output isn't reproducible on macOS at the moment so only run reproducibility tests with tarfile on macOS. Change-Id: Ib984d86ff611ec76aa39cded0ed67cedd087995a
1 parent b4686d6 commit 2f27005

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

source/ExportUnityPackage/export_unity_package.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@
281281
flags.DEFINE_string("guids_file", None, "Json file with stable guids cache.")
282282
flags.DEFINE_string("plugins_version", None, "Version of the plugins to "
283283
"package.")
284+
flags.DEFINE_boolean("use_tar", True, "Whether to use the tar command line "
285+
"application, when available, to generate archives rather "
286+
"than Python's tarfile module. NOTE: On macOS tar / gzip "
287+
"generate Unity compatible but non-reproducible archives.")
284288
flags.DEFINE_boolean(
285289
"enforce_semver", True, "Whether to enforce semver (major.minor.patch) for"
286290
"plugins_version. This is required to build UPM package.")
@@ -2479,7 +2483,7 @@ def create_archive(archive_filename, input_directory, timestamp):
24792483
platform.system() == "Darwin")
24802484
gnu_tar_available = platform.system() == "Linux"
24812485
# Whether a reproducible tar.gz is required.
2482-
if tar_available:
2486+
if tar_available and FLAGS.use_tar:
24832487
# tarfile is 10x slower than the tar command so use the command line
24842488
# tool where it's available and can generate a reproducible archive.
24852489
list_filename = os.path.join(tempfile.mkdtemp(), "input_files.txt")

source/ExportUnityPackage/export_unity_package_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import filecmp
2121
import json
2222
import os
23+
import platform
2324
import re
2425
import shutil
2526
import stat
2627
import sys
2728
import tarfile
29+
import time
2830
from absl import flags
2931
from absl.testing import absltest
3032

@@ -2618,7 +2620,12 @@ def test_package_create_archive(self):
26182620
"""Create a unitypackage archive."""
26192621
test_case_dir = os.path.join(FLAGS.test_tmpdir, "test_create_archive")
26202622
os.makedirs(test_case_dir)
2623+
use_tar = export_unity_package.FLAGS.use_tar
26212624
try:
2625+
# Disable use of tar command line application until this is reproducible on
2626+
# macOS.
2627+
export_unity_package.FLAGS.use_tar = (platform.system() != "Darwin")
2628+
26222629
archive_dir = os.path.join(test_case_dir, "archive_dir")
26232630
os.makedirs(archive_dir)
26242631
# Create some files to archive.
@@ -2655,6 +2662,9 @@ def test_package_create_archive(self):
26552662
other_archive_filename = os.path.join(test_case_dir,
26562663
"archive2.unitypackage")
26572664
os.rename(archive_filename, other_archive_filename)
2665+
# Wait before writing another archive so that any potential changes to
2666+
# timestamps can be written.
2667+
time.sleep(1)
26582668
# We create the archive with the original filename as the filename is
26592669
# embedded in the archive.
26602670
export_unity_package.PackageConfiguration.create_archive(archive_filename,
@@ -2663,6 +2673,7 @@ def test_package_create_archive(self):
26632673

26642674
finally:
26652675
shutil.rmtree(test_case_dir)
2676+
export_unity_package.FLAGS.use_tar = use_tar
26662677

26672678
def test_package_write(self):
26682679
"""Write a .unitypackage file."""

0 commit comments

Comments
 (0)