... |
... |
@@ -3,6 +3,7 @@ import pytest |
3
|
3
|
|
4
|
4
|
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
5
|
5
|
from tests.testutils import cli, filetypegenerator
|
|
6
|
+from collections import contextmanager
|
6
|
7
|
|
7
|
8
|
DATA_DIR = os.path.join(
|
8
|
9
|
os.path.dirname(os.path.realpath(__file__)),
|
... |
... |
@@ -28,16 +29,26 @@ def test_missing_patch(cli, tmpdir, datafiles): |
28
|
29
|
def test_non_regular_file_patch(cli, tmpdir, datafiles):
|
29
|
30
|
project = os.path.join(datafiles.dirname, datafiles.basename)
|
30
|
31
|
|
31
|
|
- patch_path = os.path.join(project, 'irregular_file.patch')
|
32
|
|
- for file_type in filetypegenerator.generate_file_types(patch_path):
|
33
|
|
- result = cli.run(project=project, args=[
|
34
|
|
- 'show', 'irregular.bst'
|
35
|
|
- ])
|
36
|
|
- if os.path.isfile(patch_path) and not os.path.islink(patch_path):
|
37
|
|
- result.assert_success()
|
38
|
|
- else:
|
39
|
|
- result.assert_main_error(ErrorDomain.LOAD,
|
40
|
|
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
32
|
+ # Some OSes are limited to path length of ~100 characters
|
|
33
|
+ # when binding sockets
|
|
34
|
+ @contextmanager
|
|
35
|
+ def chdir(directory):
|
|
36
|
+ old_dir = os.getcwd()
|
|
37
|
+ os.chdir(directory)
|
|
38
|
+ yield
|
|
39
|
+ os.chdir(old_dir)
|
|
40
|
+
|
|
41
|
+ patch_path = 'irregular_file.patch'
|
|
42
|
+ with chdir(directory):
|
|
43
|
+ for file_type in filetypegenerator.generate_file_types(patch_path):
|
|
44
|
+ result = cli.run(project=project, args=[
|
|
45
|
+ 'show', 'irregular.bst'
|
|
46
|
+ ])
|
|
47
|
+ if os.path.isfile(patch_path) and not os.path.islink(patch_path):
|
|
48
|
+ result.assert_success()
|
|
49
|
+ else:
|
|
50
|
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
51
|
+ LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
41
|
52
|
|
42
|
53
|
|
43
|
54
|
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|