James Ennis pushed to branch jennis/less_restrictive_pathways at BuildStream / buildstream
Commits:
-
73eddff4
by James Ennis at 2018-11-15T16:42:42Z
14 changed files:
- tests/sources/local.py
- + tests/sources/local/basic/outside_file.txt
- tests/sources/local/basic/file.txt → tests/sources/local/basic/project/file.txt
- tests/sources/local/basic/project.conf → tests/sources/local/basic/project/project.conf
- tests/sources/local/basic/target.bst → tests/sources/local/basic/project/target.bst
- tests/sources/patch.py
- tests/sources/patch/basic/file_1.patch → tests/sources/patch/basic/outside.patch
- tests/sources/patch/basic/failure-empty-dir.bst → tests/sources/patch/basic/project/failure-empty-dir.bst
- tests/sources/patch/basic/failure-nonexistent-dir.bst → tests/sources/patch/basic/project/failure-nonexistent-dir.bst
- tests/sources/patch/basic/file.txt → tests/sources/patch/basic/project/file.txt
- + tests/sources/patch/basic/project/file_1.patch
- tests/sources/patch/basic/irregular.bst → tests/sources/patch/basic/project/irregular.bst
- tests/sources/patch/basic/project.conf → tests/sources/patch/basic/project/project.conf
- tests/sources/patch/basic/target.bst → tests/sources/patch/basic/project/target.bst
Changes:
... | ... | @@ -12,7 +12,7 @@ DATA_DIR = os.path.join( |
12 | 12 |
|
13 | 13 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
14 | 14 |
def test_missing_path(cli, tmpdir, datafiles):
|
15 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
15 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
16 | 16 |
|
17 | 17 |
# Removing the local file causes preflight to fail
|
18 | 18 |
localfile = os.path.join(project, 'file.txt')
|
... | ... | @@ -26,7 +26,7 @@ def test_missing_path(cli, tmpdir, datafiles): |
26 | 26 |
|
27 | 27 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
28 | 28 |
def test_non_regular_file_or_directory(cli, tmpdir, datafiles):
|
29 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
29 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
30 | 30 |
localfile = os.path.join(project, 'file.txt')
|
31 | 31 |
|
32 | 32 |
for file_type in filetypegenerator.generate_file_types(localfile):
|
... | ... | @@ -44,7 +44,7 @@ def test_non_regular_file_or_directory(cli, tmpdir, datafiles): |
44 | 44 |
|
45 | 45 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
46 | 46 |
def test_valid_absolute_path(cli, tmpdir, datafiles):
|
47 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
47 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
48 | 48 |
|
49 | 49 |
with open(os.path.join(project, "target.bst"), 'r') as f:
|
50 | 50 |
old_yaml = f.read()
|
... | ... | @@ -60,6 +60,26 @@ def test_valid_absolute_path(cli, tmpdir, datafiles): |
60 | 60 |
result.assert_success()
|
61 | 61 |
|
62 | 62 |
|
63 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
|
64 |
+def test_invalid_absolute_path(cli, tmpdir, datafiles):
|
|
65 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
66 |
+ |
|
67 |
+ with open(os.path.join(project, "target.bst"), 'r') as f:
|
|
68 |
+ old_yaml = f.read()
|
|
69 |
+ |
|
70 |
+ outside_project = os.path.dirname(project)
|
|
71 |
+ new_yaml = old_yaml.replace("file.txt",
|
|
72 |
+ os.path.abspath(os.path.join(outside_project, "outside_file.txt")))
|
|
73 |
+ assert old_yaml != new_yaml
|
|
74 |
+ |
|
75 |
+ with open(os.path.join(project, "target.bst"), 'w') as f:
|
|
76 |
+ f.write(new_yaml)
|
|
77 |
+ |
|
78 |
+ result = cli.run(project=project, args=['show', 'target.bst'])
|
|
79 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
80 |
+ LoadErrorReason.PROJ_PATH_INVALID)
|
|
81 |
+ |
|
82 |
+ |
|
63 | 83 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path'))
|
64 | 84 |
def test_invalid_relative_path(cli, tmpdir, datafiles):
|
65 | 85 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
... | ... | @@ -71,7 +91,7 @@ def test_invalid_relative_path(cli, tmpdir, datafiles): |
71 | 91 |
|
72 | 92 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
73 | 93 |
def test_stage_file(cli, tmpdir, datafiles):
|
74 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
94 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
75 | 95 |
checkoutdir = os.path.join(str(tmpdir), "checkout")
|
76 | 96 |
|
77 | 97 |
# Build, checkout
|
1 |
+This is a text file outside the project
|
... | ... | @@ -12,7 +12,7 @@ DATA_DIR = os.path.join( |
12 | 12 |
|
13 | 13 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
14 | 14 |
def test_missing_patch(cli, tmpdir, datafiles):
|
15 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
15 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
16 | 16 |
|
17 | 17 |
# Removing the local file causes preflight to fail
|
18 | 18 |
localfile = os.path.join(project, 'file_1.patch')
|
... | ... | @@ -26,7 +26,7 @@ def test_missing_patch(cli, tmpdir, datafiles): |
26 | 26 |
|
27 | 27 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
28 | 28 |
def test_non_regular_file_patch(cli, tmpdir, datafiles):
|
29 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
29 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
30 | 30 |
|
31 | 31 |
patch_path = os.path.join(project, 'irregular_file.patch')
|
32 | 32 |
for file_type in filetypegenerator.generate_file_types(patch_path):
|
... | ... | @@ -42,7 +42,7 @@ def test_non_regular_file_patch(cli, tmpdir, datafiles): |
42 | 42 |
|
43 | 43 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
44 | 44 |
def test_valid_absolute_path(cli, tmpdir, datafiles):
|
45 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
45 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
46 | 46 |
|
47 | 47 |
with open(os.path.join(project, "target.bst"), 'r') as f:
|
48 | 48 |
old_yaml = f.read()
|
... | ... | @@ -57,6 +57,25 @@ def test_valid_absolute_path(cli, tmpdir, datafiles): |
57 | 57 |
result.assert_success()
|
58 | 58 |
|
59 | 59 |
|
60 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
|
61 |
+def test_invalid_absolute_path(cli, tmpdir, datafiles):
|
|
62 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
63 |
+ outside_project = os.path.dirname(project)
|
|
64 |
+ |
|
65 |
+ with open(os.path.join(project, "target.bst"), 'r') as f:
|
|
66 |
+ old_yaml = f.read()
|
|
67 |
+ new_yaml = old_yaml.replace("file_1.patch",
|
|
68 |
+ os.path.abspath(os.path.join(outside_project, "outside.patch")))
|
|
69 |
+ assert old_yaml != new_yaml
|
|
70 |
+ |
|
71 |
+ with open(os.path.join(project, "target.bst"), 'w') as f:
|
|
72 |
+ f.write(new_yaml)
|
|
73 |
+ |
|
74 |
+ result = cli.run(project=project, args=['show', 'target.bst'])
|
|
75 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
76 |
+ LoadErrorReason.PROJ_PATH_INVALID)
|
|
77 |
+ |
|
78 |
+ |
|
60 | 79 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path'))
|
61 | 80 |
def test_invalid_relative_path(cli, tmpdir, datafiles):
|
62 | 81 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
... | ... | @@ -68,7 +87,7 @@ def test_invalid_relative_path(cli, tmpdir, datafiles): |
68 | 87 |
|
69 | 88 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
70 | 89 |
def test_stage_and_patch(cli, tmpdir, datafiles):
|
71 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
90 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
72 | 91 |
checkoutdir = os.path.join(str(tmpdir), "checkout")
|
73 | 92 |
|
74 | 93 |
# Build, checkout
|
... | ... | @@ -84,7 +103,7 @@ def test_stage_and_patch(cli, tmpdir, datafiles): |
84 | 103 |
|
85 | 104 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
86 | 105 |
def test_stage_file_nonexistent_dir(cli, tmpdir, datafiles):
|
87 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
106 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
88 | 107 |
checkoutdir = os.path.join(str(tmpdir), "checkout")
|
89 | 108 |
|
90 | 109 |
# Fails at build time because it tries to patch into a non-existing directory
|
... | ... | @@ -95,7 +114,7 @@ def test_stage_file_nonexistent_dir(cli, tmpdir, datafiles): |
95 | 114 |
|
96 | 115 |
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
97 | 116 |
def test_stage_file_empty_dir(cli, tmpdir, datafiles):
|
98 |
- project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
117 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'project')
|
|
99 | 118 |
checkoutdir = os.path.join(str(tmpdir), "checkout")
|
100 | 119 |
|
101 | 120 |
# Fails at build time because it tries to patch with nothing else staged
|
1 |
+diff --git a/file.txt b/file.txt
|
|
2 |
+index a496efe..341ef26 100644
|
|
3 |
+--- a/file.txt
|
|
4 |
++++ b/file.txt
|
|
5 |
+@@ -1 +1 @@
|
|
6 |
+-This is a text file
|
|
7 |
++This is text file with superpowers
|