... |
... |
@@ -31,6 +31,7 @@ import shutil |
31
|
31
|
import subprocess
|
32
|
32
|
from ruamel.yaml.comments import CommentedSet
|
33
|
33
|
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, wait_for_cache_granularity
|
|
34
|
+from tests.testutils import create_artifact_share
|
34
|
35
|
|
35
|
36
|
from buildstream import _yaml
|
36
|
37
|
from buildstream._exceptions import ErrorDomain, LoadError, LoadErrorReason
|
... |
... |
@@ -615,9 +616,12 @@ def test_list(cli, tmpdir, datafiles): |
615
|
616
|
@pytest.mark.datafiles(DATA_DIR)
|
616
|
617
|
@pytest.mark.parametrize("kind", repo_kinds)
|
617
|
618
|
@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
|
618
|
|
-def test_build(cli, tmpdir, datafiles, kind, strict):
|
|
619
|
+@pytest.mark.parametrize("call_from", [("project"), ("workspace")])
|
|
620
|
+def test_build(cli, tmpdir_factory, datafiles, kind, strict, call_from):
|
|
621
|
+ tmpdir = tmpdir_factory.mktemp('')
|
619
|
622
|
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
|
620
|
623
|
checkout = os.path.join(str(tmpdir), 'checkout')
|
|
624
|
+ args_pre = ['-C', workspace] if call_from == "workspace" else []
|
621
|
625
|
|
622
|
626
|
# Modify workspace
|
623
|
627
|
shutil.rmtree(os.path.join(workspace, 'usr', 'bin'))
|
... |
... |
@@ -640,15 +644,14 @@ def test_build(cli, tmpdir, datafiles, kind, strict): |
640
|
644
|
# Build modified workspace
|
641
|
645
|
assert cli.get_element_state(project, element_name) == 'buildable'
|
642
|
646
|
assert cli.get_element_key(project, element_name) == "{:?<64}".format('')
|
643
|
|
- result = cli.run(project=project, args=['build', element_name])
|
|
647
|
+ result = cli.run(project=project, args=args_pre + ['build', element_name])
|
644
|
648
|
result.assert_success()
|
645
|
649
|
assert cli.get_element_state(project, element_name) == 'cached'
|
646
|
650
|
assert cli.get_element_key(project, element_name) != "{:?<64}".format('')
|
647
|
651
|
|
648
|
652
|
# Checkout the result
|
649
|
|
- result = cli.run(project=project, args=[
|
650
|
|
- 'checkout', element_name, checkout
|
651
|
|
- ])
|
|
653
|
+ result = cli.run(project=project,
|
|
654
|
+ args=args_pre + ['checkout', element_name, checkout])
|
652
|
655
|
result.assert_success()
|
653
|
656
|
|
654
|
657
|
# Check that the pony.conf from the modified workspace exists
|
... |
... |
@@ -1055,3 +1058,137 @@ def test_multiple_failed_builds(cli, tmpdir, datafiles): |
1055
|
1058
|
result = cli.run(project=project, args=["build", element_name])
|
1056
|
1059
|
assert "BUG" not in result.stderr
|
1057
|
1060
|
assert cli.get_element_state(project, element_name) != "cached"
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1064
|
+@pytest.mark.parametrize('subdir', [True, False], ids=["subdir", "no-subdir"])
|
|
1065
|
+def test_external_fetch(cli, datafiles, tmpdir_factory, subdir):
|
|
1066
|
+ # Fetching from a workspace outside a project doesn't fail horribly
|
|
1067
|
+ tmpdir = tmpdir_factory.mktemp('')
|
|
1068
|
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
|
1069
|
+
|
|
1070
|
+ if subdir:
|
|
1071
|
+ call_dir = os.path.join(workspace, 'usr')
|
|
1072
|
+ else:
|
|
1073
|
+ call_dir = workspace
|
|
1074
|
+
|
|
1075
|
+ result = cli.run(project=project, args=['-C', call_dir, 'fetch', element_name])
|
|
1076
|
+ result.assert_success()
|
|
1077
|
+
|
|
1078
|
+ # We already fetched it by opening the workspace, but we're also checking
|
|
1079
|
+ # `bst show` works here
|
|
1080
|
+ assert cli.get_element_state(project, element_name) == 'buildable'
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1084
|
+def test_external_push_pull(cli, datafiles, tmpdir_factory):
|
|
1085
|
+ # Pushing and pulling to/from an artifact cache works from an external workspace
|
|
1086
|
+ tmpdir = tmpdir_factory.mktemp('')
|
|
1087
|
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
|
1088
|
+
|
|
1089
|
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
|
1090
|
+ result = cli.run(project=project, args=['-C', workspace, 'build', element_name])
|
|
1091
|
+ result.assert_success()
|
|
1092
|
+
|
|
1093
|
+ cli.configure({
|
|
1094
|
+ 'artifacts': {'url': share.repo, 'push': True}
|
|
1095
|
+ })
|
|
1096
|
+
|
|
1097
|
+ result = cli.run(project=project, args=['-C', workspace, 'push', element_name])
|
|
1098
|
+ result.assert_success()
|
|
1099
|
+
|
|
1100
|
+ result = cli.run(project=project, args=['-C', workspace, 'pull', '--deps', 'all', element_name])
|
|
1101
|
+ result.assert_success()
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1105
|
+def test_external_track(cli, datafiles, tmpdir_factory):
|
|
1106
|
+ # Tracking does not get horribly confused
|
|
1107
|
+ tmpdir = tmpdir_factory.mktemp('')
|
|
1108
|
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", True)
|
|
1109
|
+
|
|
1110
|
+ # The workspace is necessarily already tracked, so we only care that
|
|
1111
|
+ # there's no weird errors.
|
|
1112
|
+ result = cli.run(project=project, args=['-C', workspace, 'track', element_name])
|
|
1113
|
+ result.assert_success()
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1117
|
+def test_external_open_other(cli, datafiles, tmpdir_factory):
|
|
1118
|
+ # >From inside an external workspace, open another workspace
|
|
1119
|
+ tmpdir1 = tmpdir_factory.mktemp('')
|
|
1120
|
+ tmpdir2 = tmpdir_factory.mktemp('')
|
|
1121
|
+ # Making use of the assumption that it's the same project in both invocations of open_workspace
|
|
1122
|
+ alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha")
|
|
1123
|
+ beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta")
|
|
1124
|
+
|
|
1125
|
+ # Closing the other element first, because I'm too lazy to create an
|
|
1126
|
+ # element without opening it
|
|
1127
|
+ result = cli.run(project=project, args=['workspace', 'close', beta_element])
|
|
1128
|
+ result.assert_success()
|
|
1129
|
+
|
|
1130
|
+ result = cli.run(project=project, args=[
|
|
1131
|
+ '-C', alpha_workspace, 'workspace', 'open', '--force', '--directory', beta_workspace, beta_element
|
|
1132
|
+ ])
|
|
1133
|
+ result.assert_success()
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1137
|
+def test_external_close_other(cli, datafiles, tmpdir_factory):
|
|
1138
|
+ # >From inside an external workspace, close the other workspace
|
|
1139
|
+ tmpdir1 = tmpdir_factory.mktemp('')
|
|
1140
|
+ tmpdir2 = tmpdir_factory.mktemp('')
|
|
1141
|
+ # Making use of the assumption that it's the same project in both invocations of open_workspace
|
|
1142
|
+ alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha")
|
|
1143
|
+ beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta")
|
|
1144
|
+
|
|
1145
|
+ result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', beta_element])
|
|
1146
|
+ result.assert_success()
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1150
|
+def test_external_close_self(cli, datafiles, tmpdir_factory):
|
|
1151
|
+ # >From inside an external workspace, close it
|
|
1152
|
+ tmpdir1 = tmpdir_factory.mktemp('')
|
|
1153
|
+ tmpdir2 = tmpdir_factory.mktemp('')
|
|
1154
|
+ # Making use of the assumption that it's the same project in both invocations of open_workspace
|
|
1155
|
+ alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha")
|
|
1156
|
+ beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta")
|
|
1157
|
+
|
|
1158
|
+ result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', alpha_element])
|
|
1159
|
+ result.assert_success()
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1163
|
+def test_external_reset_other(cli, datafiles, tmpdir_factory):
|
|
1164
|
+ tmpdir1 = tmpdir_factory.mktemp('')
|
|
1165
|
+ tmpdir2 = tmpdir_factory.mktemp('')
|
|
1166
|
+ # Making use of the assumption that it's the same project in both invocations of open_workspace
|
|
1167
|
+ alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha")
|
|
1168
|
+ beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta")
|
|
1169
|
+
|
|
1170
|
+ result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'reset', beta_element])
|
|
1171
|
+ result.assert_success()
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1175
|
+def test_external_reset_self(cli, datafiles, tmpdir):
|
|
1176
|
+ element, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
|
1177
|
+
|
|
1178
|
+ # Command succeeds
|
|
1179
|
+ result = cli.run(project=project, args=['-C', workspace, 'workspace', 'reset', element])
|
|
1180
|
+ result.assert_success()
|
|
1181
|
+
|
|
1182
|
+ # Successive commands still work (i.e. .bstproject.yaml hasn't been deleted)
|
|
1183
|
+ result = cli.run(project=project, args=['-C', workspace, 'workspace', 'list'])
|
|
1184
|
+ result.assert_success()
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
1188
|
+def test_external_list(cli, datafiles, tmpdir_factory):
|
|
1189
|
+ tmpdir = tmpdir_factory.mktemp('')
|
|
1190
|
+ # Making use of the assumption that it's the same project in both invocations of open_workspace
|
|
1191
|
+ element, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
|
1192
|
+
|
|
1193
|
+ result = cli.run(project=project, args=['-C', workspace, 'workspace', 'list'])
|
|
1194
|
+ result.assert_success()
|