Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: tools/gn/runtime_deps_unittest.cc

Issue 2940873002: Implement tracking of BUILD.gn files used to define target, toolchain or (Closed)
Patch Set: Fix compilation after rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/operators_unittest.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/runtime_deps.h" 9 #include "tools/gn/runtime_deps.h"
10 #include "tools/gn/scheduler.h" 10 #include "tools/gn/scheduler.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Tests an exe depending on different types of libraries. 43 // Tests an exe depending on different types of libraries.
44 TEST(RuntimeDeps, Libs) { 44 TEST(RuntimeDeps, Libs) {
45 TestWithScope setup; 45 TestWithScope setup;
46 Err err; 46 Err err;
47 47
48 // Dependency hierarchy: main(exe) -> static library 48 // Dependency hierarchy: main(exe) -> static library
49 // -> shared library 49 // -> shared library
50 // -> loadable module 50 // -> loadable module
51 // -> source set 51 // -> source set
52 52
53 Target stat(setup.settings(), Label(SourceDir("//"), "stat")); 53 Target stat(setup.settings(), Label(SourceDir("//"), "stat"), {});
54 InitTargetWithType(setup, &stat, Target::STATIC_LIBRARY); 54 InitTargetWithType(setup, &stat, Target::STATIC_LIBRARY);
55 stat.data().push_back("//stat.dat"); 55 stat.data().push_back("//stat.dat");
56 ASSERT_TRUE(stat.OnResolved(&err)); 56 ASSERT_TRUE(stat.OnResolved(&err));
57 57
58 Target shared(setup.settings(), Label(SourceDir("//"), "shared")); 58 Target shared(setup.settings(), Label(SourceDir("//"), "shared"), {});
59 InitTargetWithType(setup, &shared, Target::SHARED_LIBRARY); 59 InitTargetWithType(setup, &shared, Target::SHARED_LIBRARY);
60 shared.data().push_back("//shared.dat"); 60 shared.data().push_back("//shared.dat");
61 ASSERT_TRUE(shared.OnResolved(&err)); 61 ASSERT_TRUE(shared.OnResolved(&err));
62 62
63 Target loadable(setup.settings(), Label(SourceDir("//"), "loadable")); 63 Target loadable(setup.settings(), Label(SourceDir("//"), "loadable"), {});
64 InitTargetWithType(setup, &loadable, Target::LOADABLE_MODULE); 64 InitTargetWithType(setup, &loadable, Target::LOADABLE_MODULE);
65 loadable.data().push_back("//loadable.dat"); 65 loadable.data().push_back("//loadable.dat");
66 ASSERT_TRUE(loadable.OnResolved(&err)); 66 ASSERT_TRUE(loadable.OnResolved(&err));
67 67
68 Target set(setup.settings(), Label(SourceDir("//"), "set")); 68 Target set(setup.settings(), Label(SourceDir("//"), "set"), {});
69 InitTargetWithType(setup, &set, Target::SOURCE_SET); 69 InitTargetWithType(setup, &set, Target::SOURCE_SET);
70 set.data().push_back("//set.dat"); 70 set.data().push_back("//set.dat");
71 ASSERT_TRUE(set.OnResolved(&err)); 71 ASSERT_TRUE(set.OnResolved(&err));
72 72
73 Target main(setup.settings(), Label(SourceDir("//"), "main")); 73 Target main(setup.settings(), Label(SourceDir("//"), "main"), {});
74 InitTargetWithType(setup, &main, Target::EXECUTABLE); 74 InitTargetWithType(setup, &main, Target::EXECUTABLE);
75 main.private_deps().push_back(LabelTargetPair(&stat)); 75 main.private_deps().push_back(LabelTargetPair(&stat));
76 main.private_deps().push_back(LabelTargetPair(&shared)); 76 main.private_deps().push_back(LabelTargetPair(&shared));
77 main.private_deps().push_back(LabelTargetPair(&loadable)); 77 main.private_deps().push_back(LabelTargetPair(&loadable));
78 main.private_deps().push_back(LabelTargetPair(&set)); 78 main.private_deps().push_back(LabelTargetPair(&set));
79 main.data().push_back("//main.dat"); 79 main.data().push_back("//main.dat");
80 ASSERT_TRUE(main.OnResolved(&err)); 80 ASSERT_TRUE(main.OnResolved(&err));
81 81
82 std::vector<std::pair<OutputFile, const Target*>> result = 82 std::vector<std::pair<OutputFile, const Target*>> result =
83 ComputeRuntimeDeps(&main); 83 ComputeRuntimeDeps(&main);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // the output, but executables that are data deps are included. 115 // the output, but executables that are data deps are included.
116 TEST(RuntimeDeps, ExeDataDep) { 116 TEST(RuntimeDeps, ExeDataDep) {
117 TestWithScope setup; 117 TestWithScope setup;
118 Err err; 118 Err err;
119 119
120 // Dependency hierarchy: main(exe) -> datadep(exe) -> final_in(source set) 120 // Dependency hierarchy: main(exe) -> datadep(exe) -> final_in(source set)
121 // -> dep(exe) -> final_out(source set) 121 // -> dep(exe) -> final_out(source set)
122 // The final_in/out targets each have data files. final_in's should be 122 // The final_in/out targets each have data files. final_in's should be
123 // included, final_out's should not be. 123 // included, final_out's should not be.
124 124
125 Target final_in(setup.settings(), Label(SourceDir("//"), "final_in")); 125 Target final_in(setup.settings(), Label(SourceDir("//"), "final_in"), {});
126 InitTargetWithType(setup, &final_in, Target::SOURCE_SET); 126 InitTargetWithType(setup, &final_in, Target::SOURCE_SET);
127 final_in.data().push_back("//final_in.dat"); 127 final_in.data().push_back("//final_in.dat");
128 ASSERT_TRUE(final_in.OnResolved(&err)); 128 ASSERT_TRUE(final_in.OnResolved(&err));
129 129
130 Target datadep(setup.settings(), Label(SourceDir("//"), "datadep")); 130 Target datadep(setup.settings(), Label(SourceDir("//"), "datadep"), {});
131 InitTargetWithType(setup, &datadep, Target::EXECUTABLE); 131 InitTargetWithType(setup, &datadep, Target::EXECUTABLE);
132 datadep.private_deps().push_back(LabelTargetPair(&final_in)); 132 datadep.private_deps().push_back(LabelTargetPair(&final_in));
133 ASSERT_TRUE(datadep.OnResolved(&err)); 133 ASSERT_TRUE(datadep.OnResolved(&err));
134 134
135 Target final_out(setup.settings(), Label(SourceDir("//"), "final_out")); 135 Target final_out(setup.settings(), Label(SourceDir("//"), "final_out"), {});
136 InitTargetWithType(setup, &final_out, Target::SOURCE_SET); 136 InitTargetWithType(setup, &final_out, Target::SOURCE_SET);
137 final_out.data().push_back("//final_out.dat"); 137 final_out.data().push_back("//final_out.dat");
138 ASSERT_TRUE(final_out.OnResolved(&err)); 138 ASSERT_TRUE(final_out.OnResolved(&err));
139 139
140 Target dep(setup.settings(), Label(SourceDir("//"), "dep")); 140 Target dep(setup.settings(), Label(SourceDir("//"), "dep"), {});
141 InitTargetWithType(setup, &dep, Target::EXECUTABLE); 141 InitTargetWithType(setup, &dep, Target::EXECUTABLE);
142 dep.private_deps().push_back(LabelTargetPair(&final_out)); 142 dep.private_deps().push_back(LabelTargetPair(&final_out));
143 ASSERT_TRUE(dep.OnResolved(&err)); 143 ASSERT_TRUE(dep.OnResolved(&err));
144 144
145 Target main(setup.settings(), Label(SourceDir("//"), "main")); 145 Target main(setup.settings(), Label(SourceDir("//"), "main"), {});
146 InitTargetWithType(setup, &main, Target::EXECUTABLE); 146 InitTargetWithType(setup, &main, Target::EXECUTABLE);
147 main.private_deps().push_back(LabelTargetPair(&dep)); 147 main.private_deps().push_back(LabelTargetPair(&dep));
148 main.data_deps().push_back(LabelTargetPair(&datadep)); 148 main.data_deps().push_back(LabelTargetPair(&datadep));
149 ASSERT_TRUE(main.OnResolved(&err)); 149 ASSERT_TRUE(main.OnResolved(&err));
150 150
151 std::vector<std::pair<OutputFile, const Target*>> result = 151 std::vector<std::pair<OutputFile, const Target*>> result =
152 ComputeRuntimeDeps(&main); 152 ComputeRuntimeDeps(&main);
153 153
154 // The result should have deps of main, datadep, final_in.dat 154 // The result should have deps of main, datadep, final_in.dat
155 ASSERT_EQ(3u, result.size()) << GetVectorDescription(result); 155 ASSERT_EQ(3u, result.size()) << GetVectorDescription(result);
(...skipping 14 matching lines...) Expand all
170 // included. 170 // included.
171 TEST(RuntimeDeps, ActionOutputs) { 171 TEST(RuntimeDeps, ActionOutputs) {
172 TestWithScope setup; 172 TestWithScope setup;
173 Err err; 173 Err err;
174 174
175 // Dependency hierarchy: main(exe) -> datadep (action) 175 // Dependency hierarchy: main(exe) -> datadep (action)
176 // -> datadep_copy (copy) 176 // -> datadep_copy (copy)
177 // -> dep (action) 177 // -> dep (action)
178 // -> dep_copy (copy) 178 // -> dep_copy (copy)
179 179
180 Target datadep(setup.settings(), Label(SourceDir("//"), "datadep")); 180 Target datadep(setup.settings(), Label(SourceDir("//"), "datadep"), {});
181 InitTargetWithType(setup, &datadep, Target::ACTION); 181 InitTargetWithType(setup, &datadep, Target::ACTION);
182 datadep.data().push_back("//datadep.data"); 182 datadep.data().push_back("//datadep.data");
183 datadep.action_values().outputs() = 183 datadep.action_values().outputs() =
184 SubstitutionList::MakeForTest("//datadep.output"); 184 SubstitutionList::MakeForTest("//datadep.output");
185 ASSERT_TRUE(datadep.OnResolved(&err)); 185 ASSERT_TRUE(datadep.OnResolved(&err));
186 186
187 Target datadep_copy(setup.settings(), Label(SourceDir("//"), "datadep_copy")); 187 Target datadep_copy(setup.settings(), Label(SourceDir("//"), "datadep_copy"),
188 {});
188 InitTargetWithType(setup, &datadep_copy, Target::COPY_FILES); 189 InitTargetWithType(setup, &datadep_copy, Target::COPY_FILES);
189 datadep_copy.sources().push_back(SourceFile("//input")); 190 datadep_copy.sources().push_back(SourceFile("//input"));
190 datadep_copy.data().push_back("//datadep_copy.data"); 191 datadep_copy.data().push_back("//datadep_copy.data");
191 datadep_copy.action_values().outputs() = 192 datadep_copy.action_values().outputs() =
192 SubstitutionList::MakeForTest("//datadep_copy.output"); 193 SubstitutionList::MakeForTest("//datadep_copy.output");
193 ASSERT_TRUE(datadep_copy.OnResolved(&err)); 194 ASSERT_TRUE(datadep_copy.OnResolved(&err));
194 195
195 Target dep(setup.settings(), Label(SourceDir("//"), "dep")); 196 Target dep(setup.settings(), Label(SourceDir("//"), "dep"), {});
196 InitTargetWithType(setup, &dep, Target::ACTION); 197 InitTargetWithType(setup, &dep, Target::ACTION);
197 dep.data().push_back("//dep.data"); 198 dep.data().push_back("//dep.data");
198 dep.action_values().outputs() = 199 dep.action_values().outputs() =
199 SubstitutionList::MakeForTest("//dep.output"); 200 SubstitutionList::MakeForTest("//dep.output");
200 ASSERT_TRUE(dep.OnResolved(&err)); 201 ASSERT_TRUE(dep.OnResolved(&err));
201 202
202 Target dep_copy(setup.settings(), Label(SourceDir("//"), "dep_copy")); 203 Target dep_copy(setup.settings(), Label(SourceDir("//"), "dep_copy"), {});
203 InitTargetWithType(setup, &dep_copy, Target::COPY_FILES); 204 InitTargetWithType(setup, &dep_copy, Target::COPY_FILES);
204 dep_copy.sources().push_back(SourceFile("//input")); 205 dep_copy.sources().push_back(SourceFile("//input"));
205 dep_copy.data().push_back("//dep_copy/data/"); // Tests a directory. 206 dep_copy.data().push_back("//dep_copy/data/"); // Tests a directory.
206 dep_copy.action_values().outputs() = 207 dep_copy.action_values().outputs() =
207 SubstitutionList::MakeForTest("//dep_copy.output"); 208 SubstitutionList::MakeForTest("//dep_copy.output");
208 ASSERT_TRUE(dep_copy.OnResolved(&err)); 209 ASSERT_TRUE(dep_copy.OnResolved(&err));
209 210
210 Target main(setup.settings(), Label(SourceDir("//"), "main")); 211 Target main(setup.settings(), Label(SourceDir("//"), "main"), {});
211 InitTargetWithType(setup, &main, Target::EXECUTABLE); 212 InitTargetWithType(setup, &main, Target::EXECUTABLE);
212 main.private_deps().push_back(LabelTargetPair(&dep)); 213 main.private_deps().push_back(LabelTargetPair(&dep));
213 main.private_deps().push_back(LabelTargetPair(&dep_copy)); 214 main.private_deps().push_back(LabelTargetPair(&dep_copy));
214 main.data_deps().push_back(LabelTargetPair(&datadep)); 215 main.data_deps().push_back(LabelTargetPair(&datadep));
215 main.data_deps().push_back(LabelTargetPair(&datadep_copy)); 216 main.data_deps().push_back(LabelTargetPair(&datadep_copy));
216 ASSERT_TRUE(main.OnResolved(&err)); 217 ASSERT_TRUE(main.OnResolved(&err));
217 218
218 std::vector<std::pair<OutputFile, const Target*>> result = 219 std::vector<std::pair<OutputFile, const Target*>> result =
219 ComputeRuntimeDeps(&main); 220 ComputeRuntimeDeps(&main);
220 221
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 261
261 // Dependency hierarchy: 262 // Dependency hierarchy:
262 // main(exe) -> dep(bundle) -> dep(shared_library) -> dep(source set) 263 // main(exe) -> dep(bundle) -> dep(shared_library) -> dep(source set)
263 // -> dep(bundle_data) -> dep(loadable_module) 264 // -> dep(bundle_data) -> dep(loadable_module)
264 // -> data(lm.data) 265 // -> data(lm.data)
265 // -> datadep(datadep) -> data(dd.data) 266 // -> datadep(datadep) -> data(dd.data)
266 267
267 const SourceDir source_dir("//"); 268 const SourceDir source_dir("//");
268 const std::string& build_dir = setup.build_settings()->build_dir().value(); 269 const std::string& build_dir = setup.build_settings()->build_dir().value();
269 270
270 Target loadable_module(setup.settings(), 271 Target loadable_module(setup.settings(), Label(source_dir, "loadable_module"),
271 Label(source_dir, "loadable_module")); 272 {});
272 InitTargetWithType(setup, &loadable_module, Target::LOADABLE_MODULE); 273 InitTargetWithType(setup, &loadable_module, Target::LOADABLE_MODULE);
273 loadable_module.data().push_back("//lm.data"); 274 loadable_module.data().push_back("//lm.data");
274 ASSERT_TRUE(loadable_module.OnResolved(&err)); 275 ASSERT_TRUE(loadable_module.OnResolved(&err));
275 276
276 Target module_data(setup.settings(), Label(source_dir, "module_data")); 277 Target module_data(setup.settings(), Label(source_dir, "module_data"), {});
277 InitTargetWithType(setup, &module_data, Target::BUNDLE_DATA); 278 InitTargetWithType(setup, &module_data, Target::BUNDLE_DATA);
278 module_data.private_deps().push_back(LabelTargetPair(&loadable_module)); 279 module_data.private_deps().push_back(LabelTargetPair(&loadable_module));
279 module_data.bundle_data().file_rules().push_back(BundleFileRule( 280 module_data.bundle_data().file_rules().push_back(BundleFileRule(
280 nullptr, 281 nullptr,
281 std::vector<SourceFile>{SourceFile(build_dir + "loadable_module.so")}, 282 std::vector<SourceFile>{SourceFile(build_dir + "loadable_module.so")},
282 SubstitutionPattern::MakeForTest("{{bundle_resources_dir}}"))); 283 SubstitutionPattern::MakeForTest("{{bundle_resources_dir}}")));
283 ASSERT_TRUE(module_data.OnResolved(&err)); 284 ASSERT_TRUE(module_data.OnResolved(&err));
284 285
285 Target source_set(setup.settings(), Label(source_dir, "sources")); 286 Target source_set(setup.settings(), Label(source_dir, "sources"), {});
286 InitTargetWithType(setup, &source_set, Target::SOURCE_SET); 287 InitTargetWithType(setup, &source_set, Target::SOURCE_SET);
287 source_set.sources().push_back(SourceFile(source_dir.value() + "foo.cc")); 288 source_set.sources().push_back(SourceFile(source_dir.value() + "foo.cc"));
288 ASSERT_TRUE(source_set.OnResolved(&err)); 289 ASSERT_TRUE(source_set.OnResolved(&err));
289 290
290 Target dylib(setup.settings(), Label(source_dir, "dylib")); 291 Target dylib(setup.settings(), Label(source_dir, "dylib"), {});
291 dylib.set_output_prefix_override(true); 292 dylib.set_output_prefix_override(true);
292 dylib.set_output_extension(""); 293 dylib.set_output_extension("");
293 dylib.set_output_name("Bundle"); 294 dylib.set_output_name("Bundle");
294 InitTargetWithType(setup, &dylib, Target::SHARED_LIBRARY); 295 InitTargetWithType(setup, &dylib, Target::SHARED_LIBRARY);
295 dylib.private_deps().push_back(LabelTargetPair(&source_set)); 296 dylib.private_deps().push_back(LabelTargetPair(&source_set));
296 ASSERT_TRUE(dylib.OnResolved(&err)); 297 ASSERT_TRUE(dylib.OnResolved(&err));
297 298
298 Target dylib_data(setup.settings(), Label(source_dir, "dylib_data")); 299 Target dylib_data(setup.settings(), Label(source_dir, "dylib_data"), {});
299 InitTargetWithType(setup, &dylib_data, Target::BUNDLE_DATA); 300 InitTargetWithType(setup, &dylib_data, Target::BUNDLE_DATA);
300 dylib_data.private_deps().push_back(LabelTargetPair(&dylib)); 301 dylib_data.private_deps().push_back(LabelTargetPair(&dylib));
301 dylib_data.bundle_data().file_rules().push_back(BundleFileRule( 302 dylib_data.bundle_data().file_rules().push_back(BundleFileRule(
302 nullptr, std::vector<SourceFile>{SourceFile(build_dir + "dylib")}, 303 nullptr, std::vector<SourceFile>{SourceFile(build_dir + "dylib")},
303 SubstitutionPattern::MakeForTest("{{bundle_executable_dir}}"))); 304 SubstitutionPattern::MakeForTest("{{bundle_executable_dir}}")));
304 ASSERT_TRUE(dylib_data.OnResolved(&err)); 305 ASSERT_TRUE(dylib_data.OnResolved(&err));
305 306
306 Target data_dep(setup.settings(), Label(source_dir, "datadep")); 307 Target data_dep(setup.settings(), Label(source_dir, "datadep"), {});
307 InitTargetWithType(setup, &data_dep, Target::EXECUTABLE); 308 InitTargetWithType(setup, &data_dep, Target::EXECUTABLE);
308 data_dep.data().push_back("//dd.data"); 309 data_dep.data().push_back("//dd.data");
309 ASSERT_TRUE(data_dep.OnResolved(&err)); 310 ASSERT_TRUE(data_dep.OnResolved(&err));
310 311
311 Target bundle(setup.settings(), Label(source_dir, "bundle")); 312 Target bundle(setup.settings(), Label(source_dir, "bundle"), {});
312 InitTargetWithType(setup, &bundle, Target::CREATE_BUNDLE); 313 InitTargetWithType(setup, &bundle, Target::CREATE_BUNDLE);
313 const std::string root_dir(build_dir + "Bundle.framework/Versions/A/"); 314 const std::string root_dir(build_dir + "Bundle.framework/Versions/A/");
314 bundle.bundle_data().root_dir() = SourceDir(root_dir); 315 bundle.bundle_data().root_dir() = SourceDir(root_dir);
315 bundle.bundle_data().resources_dir() = SourceDir(root_dir + "Resources"); 316 bundle.bundle_data().resources_dir() = SourceDir(root_dir + "Resources");
316 bundle.bundle_data().executable_dir() = SourceDir(root_dir + "MacOS"); 317 bundle.bundle_data().executable_dir() = SourceDir(root_dir + "MacOS");
317 bundle.private_deps().push_back(LabelTargetPair(&dylib_data)); 318 bundle.private_deps().push_back(LabelTargetPair(&dylib_data));
318 bundle.private_deps().push_back(LabelTargetPair(&module_data)); 319 bundle.private_deps().push_back(LabelTargetPair(&module_data));
319 bundle.data_deps().push_back(LabelTargetPair(&data_dep)); 320 bundle.data_deps().push_back(LabelTargetPair(&data_dep));
320 bundle.data().push_back("//b.data"); 321 bundle.data().push_back("//b.data");
321 ASSERT_TRUE(bundle.OnResolved(&err)); 322 ASSERT_TRUE(bundle.OnResolved(&err));
322 323
323 Target main(setup.settings(), Label(source_dir, "main")); 324 Target main(setup.settings(), Label(source_dir, "main"), {});
324 InitTargetWithType(setup, &main, Target::EXECUTABLE); 325 InitTargetWithType(setup, &main, Target::EXECUTABLE);
325 main.data_deps().push_back(LabelTargetPair(&bundle)); 326 main.data_deps().push_back(LabelTargetPair(&bundle));
326 ASSERT_TRUE(main.OnResolved(&err)); 327 ASSERT_TRUE(main.OnResolved(&err));
327 328
328 std::vector<std::pair<OutputFile, const Target*>> result = 329 std::vector<std::pair<OutputFile, const Target*>> result =
329 ComputeRuntimeDeps(&main); 330 ComputeRuntimeDeps(&main);
330 331
331 // The result should have deps of main, datadep, final_in.dat 332 // The result should have deps of main, datadep, final_in.dat
332 ASSERT_EQ(5u, result.size()) << GetVectorDescription(result); 333 ASSERT_EQ(5u, result.size()) << GetVectorDescription(result);
333 334
(...skipping 14 matching lines...) Expand all
348 EXPECT_TRUE(base::ContainsValue(result, MakePair("../../b.data", &bundle))) 349 EXPECT_TRUE(base::ContainsValue(result, MakePair("../../b.data", &bundle)))
349 << GetVectorDescription(result); 350 << GetVectorDescription(result);
350 } 351 }
351 352
352 // Tests that a dependency duplicated in regular and data deps is processed 353 // Tests that a dependency duplicated in regular and data deps is processed
353 // as a data dep. 354 // as a data dep.
354 TEST(RuntimeDeps, Dupe) { 355 TEST(RuntimeDeps, Dupe) {
355 TestWithScope setup; 356 TestWithScope setup;
356 Err err; 357 Err err;
357 358
358 Target action(setup.settings(), Label(SourceDir("//"), "action")); 359 Target action(setup.settings(), Label(SourceDir("//"), "action"), {});
359 InitTargetWithType(setup, &action, Target::ACTION); 360 InitTargetWithType(setup, &action, Target::ACTION);
360 action.action_values().outputs() = 361 action.action_values().outputs() =
361 SubstitutionList::MakeForTest("//action.output"); 362 SubstitutionList::MakeForTest("//action.output");
362 ASSERT_TRUE(action.OnResolved(&err)); 363 ASSERT_TRUE(action.OnResolved(&err));
363 364
364 Target target(setup.settings(), Label(SourceDir("//"), "foo")); 365 Target target(setup.settings(), Label(SourceDir("//"), "foo"), {});
365 InitTargetWithType(setup, &target, Target::EXECUTABLE); 366 InitTargetWithType(setup, &target, Target::EXECUTABLE);
366 target.private_deps().push_back(LabelTargetPair(&action)); 367 target.private_deps().push_back(LabelTargetPair(&action));
367 target.data_deps().push_back(LabelTargetPair(&action)); 368 target.data_deps().push_back(LabelTargetPair(&action));
368 ASSERT_TRUE(target.OnResolved(&err)); 369 ASSERT_TRUE(target.OnResolved(&err));
369 370
370 // The results should be the executable and the copy output. 371 // The results should be the executable and the copy output.
371 std::vector<std::pair<OutputFile, const Target*>> result = 372 std::vector<std::pair<OutputFile, const Target*>> result =
372 ComputeRuntimeDeps(&target); 373 ComputeRuntimeDeps(&target);
373 EXPECT_TRUE( 374 EXPECT_TRUE(
374 base::ContainsValue(result, MakePair("../../action.output", &action))) 375 base::ContainsValue(result, MakePair("../../action.output", &action)))
(...skipping 20 matching lines...) Expand all
395 err = Err(); 396 err = Err();
396 EXPECT_TRUE(setup.ExecuteSnippet( 397 EXPECT_TRUE(setup.ExecuteSnippet(
397 "if (true) {\n" 398 "if (true) {\n"
398 " group(\"foo\") { write_runtime_deps = \"//out/Debug/foo.txt\" }\n" 399 " group(\"foo\") { write_runtime_deps = \"//out/Debug/foo.txt\" }\n"
399 "} else {\n" 400 "} else {\n"
400 " group(\"bar\") { write_runtime_deps = \"//out/Debug/bar.txt\" }\n" 401 " group(\"bar\") { write_runtime_deps = \"//out/Debug/bar.txt\" }\n"
401 "}", &err)); 402 "}", &err));
402 EXPECT_EQ(1U, setup.items().size()); 403 EXPECT_EQ(1U, setup.items().size());
403 EXPECT_EQ(1U, scheduler.GetWriteRuntimeDepsTargets().size()); 404 EXPECT_EQ(1U, scheduler.GetWriteRuntimeDepsTargets().size());
404 } 405 }
OLDNEW
« no previous file with comments | « tools/gn/operators_unittest.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698