... |
... |
@@ -44,8 +44,6 @@ DATA_DIR = os.path.join( |
44
|
44
|
)
|
45
|
45
|
|
46
|
46
|
|
47
|
|
-
|
48
|
|
-
|
49
|
47
|
def create_workspace_element(tmpdir, datafiles, kind, track, suffix='', workspace_dir=None,
|
50
|
48
|
project_path=None, element_attrs=None):
|
51
|
49
|
|
... |
... |
@@ -58,7 +56,6 @@ def create_workspace_element(tmpdir, datafiles, kind, track, suffix='', workspac |
58
|
56
|
|
59
|
57
|
# Create our repo object of the given source type with
|
60
|
58
|
# the bin files, and then collect the initial ref.
|
61
|
|
- #
|
62
|
59
|
repo = create_repo(kind, str(tmpdir))
|
63
|
60
|
ref = repo.create(bin_files_path)
|
64
|
61
|
if track:
|
... |
... |
@@ -78,50 +75,61 @@ def create_workspace_element(tmpdir, datafiles, kind, track, suffix='', workspac |
78
|
75
|
element_name))
|
79
|
76
|
return element_name, element_path, workspace_dir
|
80
|
77
|
|
81
|
|
-def open_workspaces(cli, tmpdir, datafiles, kinds, track, suffixs=None, workspace_dir=None,
|
82
|
|
- project_path=None, element_attrs=None):
|
|
78
|
+
|
|
79
|
+def create_workspace_elements(cli, tmpdir, datafiles, kinds, track, suffixs=None, workspace_dir=None,
|
|
80
|
+ project_path=None, element_attrs=None):
|
83
|
81
|
|
84
|
82
|
if not project_path:
|
85
|
83
|
project_path = os.path.join(datafiles.dirname, datafiles.basename)
|
86
|
84
|
else:
|
87
|
85
|
shutil.copytree(os.path.join(datafiles.dirname, datafiles.basename), project_path)
|
88
|
|
-
|
89
|
|
- workspace_cmd = os.path.join(project_path, 'workspace_cmd')
|
90
|
|
- os.makedirs(workspace_cmd, exist_ok=True)
|
91
|
|
-
|
|
86
|
+
|
|
87
|
+
|
92
|
88
|
results = []
|
93
|
89
|
|
94
|
90
|
if suffixs is None:
|
95
|
|
- suffixs = [None,] * len(kinds)
|
|
91
|
+ suffixs = [None, ] * len(kinds)
|
96
|
92
|
else:
|
97
|
93
|
if len(suffixs) != len(kinds):
|
98
|
94
|
raise "terable error"
|
99
|
95
|
|
100
|
96
|
for suffix, kind in zip(suffixs, kinds):
|
101
|
97
|
element_name, element_path, workspace_dir_suffix \
|
102
|
|
- = create_workspace_element(tmpdir, datafiles, kind, track, suffix, workspace_dir,
|
103
|
|
- project_path, element_attrs)
|
|
98
|
+ = create_workspace_element(tmpdir, datafiles, kind, track, suffix, workspace_dir,
|
|
99
|
+ project_path, element_attrs)
|
104
|
100
|
|
105
|
|
-
|
106
|
101
|
# Assert that there is no reference, a track & fetch is needed
|
107
|
102
|
state = cli.get_element_state(project_path, element_name)
|
108
|
103
|
if track:
|
109
|
104
|
assert state == 'no reference'
|
110
|
105
|
else:
|
111
|
106
|
assert state == 'fetch needed'
|
112
|
|
-
|
113
|
|
- # Now open the workspace, this should have the effect of automatically
|
114
|
|
- # tracking & fetching the source from the repo.
|
115
|
|
- args = ['workspace', 'open']
|
116
|
|
- if track:
|
117
|
|
- args.append('--track')
|
118
|
|
- if workspace_dir is not None:
|
119
|
|
- args.extend(['--directory', workspace_dir_suffix])
|
120
|
|
- args.extend([element_name])
|
121
|
|
- result = cli.run(cwd=workspace_cmd, project=project_path, args=args)
|
|
107
|
+ results.append((element_name, project_path, workspace_dir_suffix))
|
|
108
|
+
|
122
|
109
|
|
123
|
|
- result.assert_success()
|
|
110
|
+def open_workspaces(cli, tmpdir, datafiles, kinds, track, suffixs=None, workspace_dir=None,
|
|
111
|
+ project_path=None, element_attrs=None):
|
124
|
112
|
|
|
113
|
+ results = create_workspace_elements(cli, tmpdir, datafiles, kinds, track, suffixs, workspace_dir,
|
|
114
|
+ project_path, element_attrs)
|
|
115
|
+
|
|
116
|
+ workspace_cmd = os.path.join(project_path, 'workspace_cmd')
|
|
117
|
+ os.makedirs(workspace_cmd, exist_ok=True)
|
|
118
|
+
|
|
119
|
+ # Now open the workspace, this should have the effect of automatically
|
|
120
|
+ # tracking & fetching the source from the repo.
|
|
121
|
+ args = ['workspace', 'open']
|
|
122
|
+ if track:
|
|
123
|
+ args.append('--track')
|
|
124
|
+ if workspace_dir is not None:
|
|
125
|
+ args.extend(['--directory', workspace_dir_suffix])
|
|
126
|
+
|
|
127
|
+ args.extend([element_name for element_name, project_path, workspace_dir_suffix in results])
|
|
128
|
+ result = cli.run(cwd=workspace_cmd, project=project_path, args=args)
|
|
129
|
+
|
|
130
|
+ result.assert_success()
|
|
131
|
+
|
|
132
|
+ for element_name, project_path, workspace_dir_suffix in results:
|
125
|
133
|
# Assert that we are now buildable because the source is
|
126
|
134
|
# now cached.
|
127
|
135
|
assert cli.get_element_state(project_path, element_name) == 'buildable'
|
... |
... |
@@ -129,8 +137,7 @@ def open_workspaces(cli, tmpdir, datafiles, kinds, track, suffixs=None, workspac |
129
|
137
|
# Check that the executable hello file is found in the workspace
|
130
|
138
|
filename = os.path.join(workspace_dir_suffix, 'usr', 'bin', 'hello')
|
131
|
139
|
assert os.path.exists(filename)
|
132
|
|
- results.append((element_name, project_path, workspace_dir_suffix))
|
133
|
|
-
|
|
140
|
+
|
134
|
141
|
return results
|
135
|
142
|
|
136
|
143
|
|
... |
... |
@@ -158,6 +165,27 @@ def test_open_multi(cli, tmpdir, datafiles ): |
158
|
165
|
assert not ('.git' in workspace_lsdir)
|
159
|
166
|
assert not ('.bzr' in workspace_lsdir)
|
160
|
167
|
|
|
168
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
169
|
+def test_open_multi(cli, tmpdir, datafiles):
|
|
170
|
+
|
|
171
|
+ results = create_workspace_elements(cli, tmpdir, datafiles, kinds, track, suffixs, workspace_dir,
|
|
172
|
+ project_path, element_attrs)
|
|
173
|
+
|
|
174
|
+ workspace_cmd = os.path.join(project_path, 'workspace_cmd')
|
|
175
|
+ os.makedirs(workspace_cmd, exist_ok=True)
|
|
176
|
+
|
|
177
|
+ # Now open the workspace, this should have the effect of automatically
|
|
178
|
+ # tracking & fetching the source from the repo.
|
|
179
|
+ args = ['workspace', 'open', '--directory', 'anythingi/you/like']
|
|
180
|
+
|
|
181
|
+ args.extend([element_name for element_name, project_path, workspace_dir_suffix in results])
|
|
182
|
+ result = cli.run(cwd=workspace_cmd, project=project_path, args=args)
|
|
183
|
+
|
|
184
|
+ result.assert_main_error()
|
|
185
|
+ print(result.output)
|
|
186
|
+ print(result.stderr)
|
|
187
|
+ assert 1 == 0
|
|
188
|
+
|
161
|
189
|
@pytest.mark.datafiles(DATA_DIR)
|
162
|
190
|
def test_open_bzr_customize(cli, tmpdir, datafiles):
|
163
|
191
|
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "bzr", False)
|