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

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

Issue 565283002: GN: Add notion of 'complete' static libraries, akin to GYP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually process new argument. Duh. Created 6 years, 3 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/target.cc ('k') | tools/gn/variables.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/build_settings.h" 6 #include "tools/gn/build_settings.h"
7 #include "tools/gn/config.h" 7 #include "tools/gn/config.h"
8 #include "tools/gn/settings.h" 8 #include "tools/gn/settings.h"
9 #include "tools/gn/target.h" 9 #include "tools/gn/target.h"
10 #include "tools/gn/test_with_scope.h" 10 #include "tools/gn/test_with_scope.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 EXPECT_TRUE(b_inherited.IndexOf(&c) != static_cast<size_t>(-1)); 267 EXPECT_TRUE(b_inherited.IndexOf(&c) != static_cast<size_t>(-1));
268 EXPECT_TRUE(b_inherited.IndexOf(&d) != static_cast<size_t>(-1)); 268 EXPECT_TRUE(b_inherited.IndexOf(&d) != static_cast<size_t>(-1));
269 269
270 // A should have B in its inherited libs, but not any others (the shared 270 // A should have B in its inherited libs, but not any others (the shared
271 // library will include the static library and source set). 271 // library will include the static library and source set).
272 const UniqueVector<const Target*>& a_inherited = a.inherited_libraries(); 272 const UniqueVector<const Target*>& a_inherited = a.inherited_libraries();
273 EXPECT_EQ(1u, a_inherited.size()); 273 EXPECT_EQ(1u, a_inherited.size());
274 EXPECT_TRUE(a_inherited.IndexOf(&b) != static_cast<size_t>(-1)); 274 EXPECT_TRUE(a_inherited.IndexOf(&b) != static_cast<size_t>(-1));
275 } 275 }
276 276
277 TEST(Target, InheritCompleteStaticLib) {
278 TestWithScope setup;
279 Err err;
280
281 // Create a dependency chain:
282 // A (executable) -> B (complete static lib) -> C (source set)
283 Target a(setup.settings(), Label(SourceDir("//foo/"), "a"));
284 a.set_output_type(Target::EXECUTABLE);
285 a.SetToolchain(setup.toolchain());
286 Target b(setup.settings(), Label(SourceDir("//foo/"), "b"));
287 b.set_output_type(Target::STATIC_LIBRARY);
288 b.set_complete_static_lib(true);
289 b.SetToolchain(setup.toolchain());
290 Target c(setup.settings(), Label(SourceDir("//foo/"), "c"));
291 c.set_output_type(Target::SOURCE_SET);
292 c.SetToolchain(setup.toolchain());
293 a.deps().push_back(LabelTargetPair(&b));
294 b.deps().push_back(LabelTargetPair(&c));
295
296 ASSERT_TRUE(c.OnResolved(&err));
297 ASSERT_TRUE(b.OnResolved(&err));
298 ASSERT_TRUE(a.OnResolved(&err));
299
300 // B should have C in its inherited libs.
301 const UniqueVector<const Target*>& b_inherited = b.inherited_libraries();
302 EXPECT_EQ(1u, b_inherited.size());
303 EXPECT_TRUE(b_inherited.IndexOf(&c) != static_cast<size_t>(-1));
304
305 // A should have B in its inherited libs, but not any others (the complete
306 // static library will include the source set).
307 const UniqueVector<const Target*>& a_inherited = a.inherited_libraries();
308 EXPECT_EQ(1u, a_inherited.size());
309 EXPECT_TRUE(a_inherited.IndexOf(&b) != static_cast<size_t>(-1));
310 }
311
277 TEST(Target, GetComputedOutputName) { 312 TEST(Target, GetComputedOutputName) {
278 TestWithScope setup; 313 TestWithScope setup;
279 Err err; 314 Err err;
280 315
281 // Basic target with no prefix (executable type tool in the TestWithScope has 316 // Basic target with no prefix (executable type tool in the TestWithScope has
282 // no prefix) or output name. 317 // no prefix) or output name.
283 Target basic(setup.settings(), Label(SourceDir("//foo/"), "bar")); 318 Target basic(setup.settings(), Label(SourceDir("//foo/"), "bar"));
284 basic.set_output_type(Target::EXECUTABLE); 319 basic.set_output_type(Target::EXECUTABLE);
285 basic.SetToolchain(setup.toolchain()); 320 basic.SetToolchain(setup.toolchain());
286 ASSERT_TRUE(basic.OnResolved(&err)); 321 ASSERT_TRUE(basic.OnResolved(&err));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 ASSERT_TRUE(test.OnResolved(&err)); 430 ASSERT_TRUE(test.OnResolved(&err));
396 431
397 // "product" is a non-test depending on testlib. This should fail. 432 // "product" is a non-test depending on testlib. This should fail.
398 Target product(setup.settings(), Label(SourceDir("//app/"), "product")); 433 Target product(setup.settings(), Label(SourceDir("//app/"), "product"));
399 product.set_testonly(false); 434 product.set_testonly(false);
400 product.set_output_type(Target::EXECUTABLE); 435 product.set_output_type(Target::EXECUTABLE);
401 product.deps().push_back(LabelTargetPair(&testlib)); 436 product.deps().push_back(LabelTargetPair(&testlib));
402 product.SetToolchain(setup.toolchain()); 437 product.SetToolchain(setup.toolchain());
403 ASSERT_FALSE(product.OnResolved(&err)); 438 ASSERT_FALSE(product.OnResolved(&err));
404 } 439 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698