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

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

Issue 551843006: GN: fix datadeps visibility check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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') | no next file » | 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // it as user-set so we check visibility. This check should fail. 366 // it as user-set so we check visibility. This check should fail.
367 Target a(setup.settings(), Label(SourceDir("//app/"), "a")); 367 Target a(setup.settings(), Label(SourceDir("//app/"), "a"));
368 a.set_output_type(Target::EXECUTABLE); 368 a.set_output_type(Target::EXECUTABLE);
369 a.deps().push_back(LabelTargetPair(&b)); 369 a.deps().push_back(LabelTargetPair(&b));
370 IdentifierNode origin; // Dummy origin. 370 IdentifierNode origin; // Dummy origin.
371 a.deps()[0].origin = &origin; 371 a.deps()[0].origin = &origin;
372 a.SetToolchain(setup.toolchain()); 372 a.SetToolchain(setup.toolchain());
373 ASSERT_FALSE(a.OnResolved(&err)); 373 ASSERT_FALSE(a.OnResolved(&err));
374 } 374 }
375 375
376 // Test visibility with a single datadep.
377 TEST(Target, VisibilityDatadeps) {
378 TestWithScope setup;
379 Err err;
380
381 Target b(setup.settings(), Label(SourceDir("//public/"), "b"));
382 b.set_output_type(Target::STATIC_LIBRARY);
383 b.SetToolchain(setup.toolchain());
384 b.visibility().SetPublic();
385 ASSERT_TRUE(b.OnResolved(&err));
386
387 // Make a target depending on "b". The dependency must have an origin to mark
388 // it as user-set so we check visibility. This check should fail.
389 Target a(setup.settings(), Label(SourceDir("//app/"), "a"));
390 a.set_output_type(Target::EXECUTABLE);
391 a.datadeps().push_back(LabelTargetPair(&b));
392 IdentifierNode origin; // Dummy origin.
393 a.datadeps()[0].origin = &origin;
394 a.SetToolchain(setup.toolchain());
395 ASSERT_TRUE(a.OnResolved(&err)) << err.help_text();
396 }
397
376 // Tests that A -> Group -> B where the group is visible from A but B isn't, 398 // Tests that A -> Group -> B where the group is visible from A but B isn't,
377 // passes visibility even though the group's deps get expanded into A. 399 // passes visibility even though the group's deps get expanded into A.
378 TEST(Target, VisibilityGroup) { 400 TEST(Target, VisibilityGroup) {
379 TestWithScope setup; 401 TestWithScope setup;
380 Err err; 402 Err err;
381 403
382 IdentifierNode origin; // Dummy origin. 404 IdentifierNode origin; // Dummy origin.
383 405
384 // B has private visibility. This lets the group see it since the group is in 406 // B has private visibility. This lets the group see it since the group is in
385 // the same directory. 407 // the same directory.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ASSERT_TRUE(test.OnResolved(&err)); 452 ASSERT_TRUE(test.OnResolved(&err));
431 453
432 // "product" is a non-test depending on testlib. This should fail. 454 // "product" is a non-test depending on testlib. This should fail.
433 Target product(setup.settings(), Label(SourceDir("//app/"), "product")); 455 Target product(setup.settings(), Label(SourceDir("//app/"), "product"));
434 product.set_testonly(false); 456 product.set_testonly(false);
435 product.set_output_type(Target::EXECUTABLE); 457 product.set_output_type(Target::EXECUTABLE);
436 product.deps().push_back(LabelTargetPair(&testlib)); 458 product.deps().push_back(LabelTargetPair(&testlib));
437 product.SetToolchain(setup.toolchain()); 459 product.SetToolchain(setup.toolchain());
438 ASSERT_FALSE(product.OnResolved(&err)); 460 ASSERT_FALSE(product.OnResolved(&err));
439 } 461 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698