From 2e71833471ace17e31371339c6820536fc567835 Mon Sep 17 00:00:00 2001 From: Mitchell Hentges Date: Thu, 7 May 2020 23:41:35 +0000 Subject: [PATCH] Bug 1636209: resolves tests that were incorrectly marked as xfail r=tomprince When handling bug 1632429, I found some tests that worked on Python 2, but not Python 3. They were marked accordingly as "expected failures". However, my system version of Python is 3.8, while CI (and a non-trivial number of devs, probably) use 3.6. Some of these tests marked as xfail were actually still working on versions of Python until 3.8. The failure of this test was due to a change in default tarfile format. Explicitly setting this format makes the tests pass in all relevant python versions. Differential Revision: https://phabricator.services.mozilla.com/D74337 --- python/mozbuild/mozpack/archive.py | 5 ++++- taskcluster/taskgraph/test/test_util_docker.py | 15 --------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/python/mozbuild/mozpack/archive.py b/python/mozbuild/mozpack/archive.py index 44fde17d84f5..06f5b4df7ac2 100644 --- a/python/mozbuild/mozpack/archive.py +++ b/python/mozbuild/mozpack/archive.py @@ -30,7 +30,10 @@ def create_tar_from_files(fp, files): FUTURE accept a filename argument (or create APIs to write files) """ - with tarfile.open(name='', mode='w', fileobj=fp, dereference=True) as tf: + # The format is explicitly set to tarfile.GNU_FORMAT, because this default format + # has been changed in Python 3.8. + with tarfile.open(name='', mode='w', fileobj=fp, dereference=True, + format=tarfile.GNU_FORMAT) as tf: for archive_path, f in sorted(files.items()): if not isinstance(f, BaseFile): f = File(f) diff --git a/taskcluster/taskgraph/test/test_util_docker.py b/taskcluster/taskgraph/test/test_util_docker.py index e1ac0da3d34d..099fbb67f5ff 100644 --- a/taskcluster/taskgraph/test/test_util_docker.py +++ b/taskcluster/taskgraph/test/test_util_docker.py @@ -7,12 +7,10 @@ from __future__ import absolute_import, print_function, unicode_literals import os import shutil import stat -import sys import tarfile import tempfile import unittest import mock -import pytest import taskcluster_urls as liburls from taskgraph.util import docker @@ -24,10 +22,6 @@ MODE_STANDARD = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH @mock.patch.dict('os.environ', {'TASKCLUSTER_ROOT_URL': liburls.test_root_url()}) class TestDocker(unittest.TestCase): - - @pytest.mark.xfail( - sys.version_info >= (3, 0), reason="python3 migration is not complete" - ) def test_generate_context_hash(self): tmpdir = tempfile.mkdtemp() try: @@ -81,9 +75,6 @@ class TestDocker(unittest.TestCase): with MockedOpen(files): self.assertEqual(docker.docker_image('myimage', by_tag=True), "mozilla/myimage:1.2.3") - @pytest.mark.xfail( - sys.version_info >= (3, 0), reason="python3 migration is not complete" - ) def test_create_context_tar_basic(self): tmp = tempfile.mkdtemp() try: @@ -110,9 +101,6 @@ class TestDocker(unittest.TestCase): finally: shutil.rmtree(tmp) - @pytest.mark.xfail( - sys.version_info >= (3, 0), reason="python3 migration is not complete" - ) def test_create_context_topsrcdir_files(self): tmp = tempfile.mkdtemp() try: @@ -183,9 +171,6 @@ class TestDocker(unittest.TestCase): finally: shutil.rmtree(tmp) - @pytest.mark.xfail( - sys.version_info >= (3, 0), reason="python3 migration is not complete" - ) def test_create_context_extra_directory(self): tmp = tempfile.mkdtemp() try: