Jonathan Maw pushed to branch jonathan/wsl-tests at BuildStream / buildstream
Commits:
-
76712c2a
by Jonathan Maw at 2019-01-24T18:03:51Z
2 changed files:
Changes:
| ... | ... | @@ -3,6 +3,7 @@ import pytest |
| 3 | 3 |
from buildstream import _yaml
|
| 4 | 4 |
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
| 5 | 5 |
from tests.testutils import cli, filetypegenerator
|
| 6 |
+from contextlib import contextmanager
|
|
| 6 | 7 |
|
| 7 | 8 |
|
| 8 | 9 |
# Project directory
|
| ... | ... | @@ -12,6 +13,16 @@ DATA_DIR = os.path.join( |
| 12 | 13 |
)
|
| 13 | 14 |
|
| 14 | 15 |
|
| 16 |
+# Some OSes are limited to path length of ~100 characters
|
|
| 17 |
+# when binding sockets
|
|
| 18 |
+@contextmanager
|
|
| 19 |
+def chdir(directory):
|
|
| 20 |
+ old_dir = os.getcwd()
|
|
| 21 |
+ os.chdir(directory)
|
|
| 22 |
+ yield
|
|
| 23 |
+ os.chdir(old_dir)
|
|
| 24 |
+ |
|
| 25 |
+ |
|
| 15 | 26 |
@pytest.mark.datafiles(os.path.join(DATA_DIR))
|
| 16 | 27 |
def test_missing_project_conf(cli, datafiles):
|
| 17 | 28 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
| ... | ... | @@ -108,14 +119,15 @@ def test_missing_element_path_directory(cli, datafiles): |
| 108 | 119 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
|
| 109 | 120 |
def test_element_path_not_a_directory(cli, datafiles):
|
| 110 | 121 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
| 111 |
- path = os.path.join(project, 'elements')
|
|
| 112 |
- for file_type in filetypegenerator.generate_file_types(path):
|
|
| 113 |
- result = cli.run(project=project, args=['workspace', 'list'])
|
|
| 114 |
- if not os.path.isdir(path):
|
|
| 115 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
| 116 |
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 117 |
- else:
|
|
| 118 |
- result.assert_success()
|
|
| 122 |
+ path = 'elements'
|
|
| 123 |
+ with chdir(project):
|
|
| 124 |
+ for file_type in filetypegenerator.generate_file_types(path):
|
|
| 125 |
+ result = cli.run(project=project, args=['workspace', 'list'])
|
|
| 126 |
+ if not os.path.isdir(path):
|
|
| 127 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
| 128 |
+ LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 129 |
+ else:
|
|
| 130 |
+ result.assert_success()
|
|
| 119 | 131 |
|
| 120 | 132 |
|
| 121 | 133 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
|
| ... | ... | @@ -129,14 +141,15 @@ def test_missing_local_plugin_directory(cli, datafiles): |
| 129 | 141 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
|
| 130 | 142 |
def test_local_plugin_not_directory(cli, datafiles):
|
| 131 | 143 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
| 132 |
- path = os.path.join(project, 'plugins')
|
|
| 133 |
- for file_type in filetypegenerator.generate_file_types(path):
|
|
| 134 |
- result = cli.run(project=project, args=['workspace', 'list'])
|
|
| 135 |
- if not os.path.isdir(path):
|
|
| 136 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
| 137 |
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 138 |
- else:
|
|
| 139 |
- result.assert_success()
|
|
| 144 |
+ path = 'plugins'
|
|
| 145 |
+ with chdir(project):
|
|
| 146 |
+ for file_type in filetypegenerator.generate_file_types(path):
|
|
| 147 |
+ result = cli.run(project=project, args=['workspace', 'list'])
|
|
| 148 |
+ if not os.path.isdir(path):
|
|
| 149 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
| 150 |
+ LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 151 |
+ else:
|
|
| 152 |
+ result.assert_success()
|
|
| 140 | 153 |
|
| 141 | 154 |
|
| 142 | 155 |
@pytest.mark.datafiles(DATA_DIR)
|
| ... | ... | @@ -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 contextlib import contextmanager
|
|
| 6 | 7 |
|
| 7 | 8 |
DATA_DIR = os.path.join(
|
| 8 | 9 |
os.path.dirname(os.path.realpath(__file__)),
|
| ... | ... | @@ -27,19 +28,29 @@ def test_missing_path(cli, tmpdir, datafiles): |
| 27 | 28 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
| 28 | 29 |
def test_non_regular_file_or_directory(cli, tmpdir, datafiles):
|
| 29 | 30 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
| 30 |
- localfile = os.path.join(project, 'file.txt')
|
|
| 31 |
- |
|
| 32 |
- for file_type in filetypegenerator.generate_file_types(localfile):
|
|
| 33 |
- result = cli.run(project=project, args=[
|
|
| 34 |
- 'show', 'target.bst'
|
|
| 35 |
- ])
|
|
| 36 |
- if os.path.isdir(localfile) and not os.path.islink(localfile):
|
|
| 37 |
- result.assert_success()
|
|
| 38 |
- elif os.path.isfile(localfile) and not os.path.islink(localfile):
|
|
| 39 |
- result.assert_success()
|
|
| 40 |
- else:
|
|
| 41 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
| 42 |
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 31 |
+ localfile = 'file.txt'
|
|
| 32 |
+ |
|
| 33 |
+ # Some OSes are limited to path length of ~100 characters
|
|
| 34 |
+ # when binding sockets
|
|
| 35 |
+ @contextmanager
|
|
| 36 |
+ def chdir(directory):
|
|
| 37 |
+ old_dir = os.getcwd()
|
|
| 38 |
+ os.chdir(directory)
|
|
| 39 |
+ yield
|
|
| 40 |
+ os.chdir(old_dir)
|
|
| 41 |
+ |
|
| 42 |
+ with chdir(project):
|
|
| 43 |
+ for file_type in filetypegenerator.generate_file_types(localfile):
|
|
| 44 |
+ result = cli.run(project=project, args=[
|
|
| 45 |
+ 'show', 'target.bst'
|
|
| 46 |
+ ])
|
|
| 47 |
+ if os.path.isdir(localfile) and not os.path.islink(localfile):
|
|
| 48 |
+ result.assert_success()
|
|
| 49 |
+ elif os.path.isfile(localfile) and not os.path.islink(localfile):
|
|
| 50 |
+ result.assert_success()
|
|
| 51 |
+ else:
|
|
| 52 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
| 53 |
+ LoadErrorReason.PROJ_PATH_INVALID_KIND)
|
|
| 43 | 54 |
|
| 44 | 55 |
|
| 45 | 56 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
