OLD | NEW |
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 "tools/gn/target.h" | 5 #include "tools/gn/target.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 | 264 |
265 TEST(Target, GetComputedOutputName) { | 265 TEST(Target, GetComputedOutputName) { |
266 TestWithScope setup; | 266 TestWithScope setup; |
267 Err err; | 267 Err err; |
268 | 268 |
269 // Basic target with no prefix (executable type tool in the TestWithScope has | 269 // Basic target with no prefix (executable type tool in the TestWithScope has |
270 // no prefix) or output name. | 270 // no prefix) or output name. |
271 TestTarget basic(setup, "//foo:bar", Target::EXECUTABLE); | 271 TestTarget basic(setup, "//foo:bar", Target::EXECUTABLE); |
272 ASSERT_TRUE(basic.OnResolved(&err)); | 272 ASSERT_TRUE(basic.OnResolved(&err)); |
273 EXPECT_EQ("bar", basic.GetComputedOutputName(false)); | 273 EXPECT_EQ("bar", basic.GetComputedOutputName()); |
274 EXPECT_EQ("bar", basic.GetComputedOutputName(true)); | |
275 | 274 |
276 // Target with no prefix but an output name. | 275 // Target with no prefix but an output name. |
277 TestTarget with_name(setup, "//foo:bar", Target::EXECUTABLE); | 276 TestTarget with_name(setup, "//foo:bar", Target::EXECUTABLE); |
278 with_name.set_output_name("myoutput"); | 277 with_name.set_output_name("myoutput"); |
279 ASSERT_TRUE(with_name.OnResolved(&err)); | 278 ASSERT_TRUE(with_name.OnResolved(&err)); |
280 EXPECT_EQ("myoutput", with_name.GetComputedOutputName(false)); | 279 EXPECT_EQ("myoutput", with_name.GetComputedOutputName()); |
281 EXPECT_EQ("myoutput", with_name.GetComputedOutputName(true)); | |
282 | 280 |
283 // Target with a "lib" prefix (the static library tool in the TestWithScope | 281 // Target with a "lib" prefix (the static library tool in the TestWithScope |
284 // should specify a "lib" output prefix). | 282 // should specify a "lib" output prefix). |
285 TestTarget with_prefix(setup, "//foo:bar", Target::STATIC_LIBRARY); | 283 TestTarget with_prefix(setup, "//foo:bar", Target::STATIC_LIBRARY); |
286 ASSERT_TRUE(with_prefix.OnResolved(&err)); | 284 ASSERT_TRUE(with_prefix.OnResolved(&err)); |
287 EXPECT_EQ("bar", with_prefix.GetComputedOutputName(false)); | 285 EXPECT_EQ("libbar", with_prefix.GetComputedOutputName()); |
288 EXPECT_EQ("libbar", with_prefix.GetComputedOutputName(true)); | |
289 | 286 |
290 // Target with a "lib" prefix that already has it applied. The prefix should | 287 // Target with a "lib" prefix that already has it applied. The prefix should |
291 // not duplicate something already in the target name. | 288 // not duplicate something already in the target name. |
292 TestTarget dup_prefix(setup, "//foo:bar", Target::STATIC_LIBRARY); | 289 TestTarget dup_prefix(setup, "//foo:bar", Target::STATIC_LIBRARY); |
293 dup_prefix.set_output_name("libbar"); | 290 dup_prefix.set_output_name("libbar"); |
294 ASSERT_TRUE(dup_prefix.OnResolved(&err)); | 291 ASSERT_TRUE(dup_prefix.OnResolved(&err)); |
295 EXPECT_EQ("libbar", dup_prefix.GetComputedOutputName(false)); | 292 EXPECT_EQ("libbar", dup_prefix.GetComputedOutputName()); |
296 EXPECT_EQ("libbar", dup_prefix.GetComputedOutputName(true)); | 293 |
| 294 // Target with an output prefix override should not have a prefix. |
| 295 TestTarget override_prefix(setup, "//foo:bar", Target::SHARED_LIBRARY); |
| 296 override_prefix.set_output_prefix_override(true); |
| 297 ASSERT_TRUE(dup_prefix.OnResolved(&err)); |
| 298 EXPECT_EQ("bar", override_prefix.GetComputedOutputName()); |
297 } | 299 } |
298 | 300 |
299 // Test visibility failure case. | 301 // Test visibility failure case. |
300 TEST(Target, VisibilityFails) { | 302 TEST(Target, VisibilityFails) { |
301 TestWithScope setup; | 303 TestWithScope setup; |
302 Err err; | 304 Err err; |
303 | 305 |
304 TestTarget b(setup, "//private:b", Target::STATIC_LIBRARY); | 306 TestTarget b(setup, "//private:b", Target::STATIC_LIBRARY); |
305 b.visibility().SetPrivate(b.label().dir()); | 307 b.visibility().SetPrivate(b.label().dir()); |
306 ASSERT_TRUE(b.OnResolved(&err)); | 308 ASSERT_TRUE(b.OnResolved(&err)); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); | 876 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); |
875 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); | 877 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); |
876 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u); | 878 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u); |
877 | 879 |
878 // E does not have any bundle_data information but gets a list of | 880 // E does not have any bundle_data information but gets a list of |
879 // bundle_deps to propagate them during target resolution. | 881 // bundle_deps to propagate them during target resolution. |
880 ASSERT_TRUE(e.bundle_data().file_rules().empty()); | 882 ASSERT_TRUE(e.bundle_data().file_rules().empty()); |
881 ASSERT_TRUE(e.bundle_data().asset_catalog_sources().empty()); | 883 ASSERT_TRUE(e.bundle_data().asset_catalog_sources().empty()); |
882 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u); | 884 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u); |
883 } | 885 } |
OLD | NEW |