summarylogtreecommitdiffstats
path: root/0002-unittests-Add-a-helper-for-copying-source-trees.patch
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig)2024-04-09 15:03:42 +0300
committerEcho J2024-04-09 15:03:42 +0300
commitc39573cbbbe7a2f9c78be88cbf39ddcdc649338f (patch)
tree2df1d56ca1d9b351c6372df029049c1f74a28879 /0002-unittests-Add-a-helper-for-copying-source-trees.patch
parente9c6e0b2e58f499233424a85d589c7d54638d4b5 (diff)
downloadaur-meson-rust.tar.gz
Update to 1.4.0
This is a squashed version of b0a6e63fedf5c030ea7b169b2f67d6ac0b06df0a^..1ef55a5d5069da4825a249124766be8c9a9e696c commits
Diffstat (limited to '0002-unittests-Add-a-helper-for-copying-source-trees.patch')
-rw-r--r--0002-unittests-Add-a-helper-for-copying-source-trees.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/0002-unittests-Add-a-helper-for-copying-source-trees.patch b/0002-unittests-Add-a-helper-for-copying-source-trees.patch
new file mode 100644
index 000000000000..c4b352552fb4
--- /dev/null
+++ b/0002-unittests-Add-a-helper-for-copying-source-trees.patch
@@ -0,0 +1,57 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Dylan Baker <dylan@pnwbakers.com>
+Date: Mon, 11 Mar 2024 11:31:05 -0700
+Subject: [PATCH] unittests: Add a helper for copying source trees
+
+This is a useful thing to do when a test needs to modify the source
+tree, as it prevents races between tests.
+---
+ unittests/baseplatformtests.py | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
+index 6125ed933209..93bfc8905b73 100644
+--- a/unittests/baseplatformtests.py
++++ b/unittests/baseplatformtests.py
+@@ -1,14 +1,17 @@
+ # SPDX-License-Identifier: Apache-2.0
+ # Copyright 2016-2021 The Meson development team
++# Copyright © 2024 Intel Corporation
+
++from __future__ import annotations
+ from pathlib import PurePath
+ from unittest import mock, TestCase, SkipTest
+ import json
+ import io
+ import os
+ import re
+ import subprocess
+ import sys
++import shutil
+ import tempfile
+ import typing as T
+
+@@ -492,3 +495,23 @@ class BasePlatformTests(TestCase):
+
+ def assertLength(self, val, length):
+ assert len(val) == length, f'{val} is not length {length}'
++
++ def copy_srcdir(self, srcdir: str) -> str:
++ """Copies a source tree and returns that copy.
++
++ ensures that the copied tree is deleted after running.
++
++ :param srcdir: The locaiton of the source tree to copy
++ :return: The location of the copy
++ """
++ dest = tempfile.mkdtemp()
++ self.addCleanup(windows_proof_rmtree, dest)
++
++ # shutil.copytree expects the destinatin directory to not exist, Once
++ # python 3.8 is required the `dirs_exist_ok` parameter negates the need
++ # for this
++ dest = os.path.join(dest, 'subdir')
++
++ shutil.copytree(srcdir, dest)
++
++ return dest