summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-01-03 13:58:32 +0000
committerChandan Singh <csingh43@bloomberg.net>2019-01-03 13:58:32 +0000
commitc3c2fc06dd02b3e86c96b9d1ceb245734842de38 (patch)
treea0b8621b8ef999400700e5bc05c2b54d6aa55859
parent32c47d1cec58c8832f526a5df7a0eb23251ac7e1 (diff)
downloadbuildstream-chandan/fix-bad-filename-mini-disaster.tar.gz
tests/frontend/buildcheckout.py: Fix bad filename issue for Windowschandan/fix-bad-filename-mini-disaster
In BuildStream/buildstream!1028, we added a test specifically to test that BuildStream correctly raises an warning when the name of an element contains characters that are invalid on Windows. Unfortunately, we didn't see it coming that it would make it impossible to checkout this branch on Windows. Fix it by generating this file, only if we are not running on Windows. * tests/testutils/site.py: Add `IS_WINDOWS` check * tests/frontend/buildcheckout.py: Generate file with invalid filename on the fly * Remove tests/frontend/project/elements/invalid-chars. Fixes #842. Note that this may still cause issues on WSL when running tests on a shared filesystem, but that seems to be a generic issue on WSL with `os.rename`.
-rw-r--r--tests/frontend/buildcheckout.py24
-rw-r--r--tests/frontend/project/elements/invalid-chars|<>-in-name.bst4
-rw-r--r--tests/testutils/site.py1
3 files changed, 24 insertions, 5 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index dc7ce6847..287fb6034 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -3,6 +3,7 @@ import tarfile
import hashlib
import pytest
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
+from tests.testutils.site import IS_WINDOWS
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
@@ -85,16 +86,37 @@ def test_build_invalid_suffix_dep(datafiles, cli, strict, hardlinks):
result.assert_main_error(ErrorDomain.LOAD, "bad-element-suffix")
+@pytest.mark.skipif(IS_WINDOWS, reason='Not available on Windows')
@pytest.mark.datafiles(DATA_DIR)
def test_build_invalid_filename_chars(datafiles, cli):
project = os.path.join(datafiles.dirname, datafiles.basename)
- result = cli.run(project=project, args=strict_args(['build', 'invalid-chars|<>-in-name.bst'], 'non-strict'))
+ element_name = 'invalid-chars|<>-in-name.bst'
+
+ # The name of this file contains characters that are not allowed by
+ # BuildStream, using it should raise a warning.
+ element = {
+ 'kind': 'stack',
+ }
+ _yaml.dump(element, os.path.join(project, 'elements', element_name))
+
+ result = cli.run(project=project, args=strict_args(['build', element_name], 'non-strict'))
result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name")
+@pytest.mark.skipif(IS_WINDOWS, reason='Not available on Windows')
@pytest.mark.datafiles(DATA_DIR)
def test_build_invalid_filename_chars_dep(datafiles, cli):
project = os.path.join(datafiles.dirname, datafiles.basename)
+ element_name = 'invalid-chars|<>-in-name.bst'
+
+ # The name of this file contains characters that are not allowed by
+ # BuildStream, and is listed as a dependency of 'invalid-chars-in-dep.bst'.
+ # This should also raise a warning.
+ element = {
+ 'kind': 'stack',
+ }
+ _yaml.dump(element, os.path.join(project, 'elements', element_name))
+
result = cli.run(project=project, args=strict_args(['build', 'invalid-chars-in-dep.bst'], 'non-strict'))
result.assert_main_error(ErrorDomain.LOAD, "bad-characters-in-name")
diff --git a/tests/frontend/project/elements/invalid-chars|<>-in-name.bst b/tests/frontend/project/elements/invalid-chars|<>-in-name.bst
deleted file mode 100644
index bc6a13110..000000000
--- a/tests/frontend/project/elements/invalid-chars|<>-in-name.bst
+++ /dev/null
@@ -1,4 +0,0 @@
-kind: stack
-description: |
- The name of this files contains characters that are not allowed by
- BuildStream, using it should raise a warning.
diff --git a/tests/testutils/site.py b/tests/testutils/site.py
index c7625cccf..6ef22babb 100644
--- a/tests/testutils/site.py
+++ b/tests/testutils/site.py
@@ -52,5 +52,6 @@ except ImportError:
HAVE_ARPY = False
IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux')
+IS_WINDOWS = (os.name == 'nt')
MACHINE_ARCH = Platform.get_host_arch()