OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/functions.h" | 6 #include "tools/gn/functions.h" |
7 #include "tools/gn/test_with_scope.h" | 7 #include "tools/gn/test_with_scope.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 TEST_F(GetLabelInfoTest, BadInput) { | 43 TEST_F(GetLabelInfoTest, BadInput) { |
44 EXPECT_EQ("", Call(":name", "incorrect_value")); | 44 EXPECT_EQ("", Call(":name", "incorrect_value")); |
45 EXPECT_EQ("", Call("", "name")); | 45 EXPECT_EQ("", Call("", "name")); |
46 } | 46 } |
47 | 47 |
48 TEST_F(GetLabelInfoTest, Name) { | 48 TEST_F(GetLabelInfoTest, Name) { |
49 EXPECT_EQ("name", Call(":name", "name")); | 49 EXPECT_EQ("name", Call(":name", "name")); |
50 EXPECT_EQ("name", Call("//foo/bar:name", "name")); | 50 EXPECT_EQ("name", Call("//foo/bar:name", "name")); |
| 51 EXPECT_EQ("name", Call("//foo/bar:name(//other:tc)", "name")); |
51 } | 52 } |
52 | 53 |
53 TEST_F(GetLabelInfoTest, Dir) { | 54 TEST_F(GetLabelInfoTest, Dir) { |
54 EXPECT_EQ("//src/foo", Call(":name", "dir")); | 55 EXPECT_EQ("//src/foo", Call(":name", "dir")); |
55 EXPECT_EQ("//foo/bar", Call("//foo/bar:baz", "dir")); | 56 EXPECT_EQ("//foo/bar", Call("//foo/bar:baz", "dir")); |
| 57 EXPECT_EQ("//foo/bar", Call("//foo/bar:baz(//other:tc)", "dir")); |
56 } | 58 } |
57 | 59 |
58 TEST_F(GetLabelInfoTest, RootOutDir) { | 60 TEST_F(GetLabelInfoTest, RootOutDir) { |
59 EXPECT_EQ("//out/Debug", Call(":name", "root_out_dir")); | 61 EXPECT_EQ("//out/Debug", Call(":name", "root_out_dir")); |
60 EXPECT_EQ("//out/Debug/random", | 62 EXPECT_EQ("//out/Debug/random", |
61 Call(":name(//toolchain:random)", "root_out_dir")); | 63 Call(":name(//toolchain:random)", "root_out_dir")); |
62 } | 64 } |
63 | 65 |
64 TEST_F(GetLabelInfoTest, RootGetDir) { | 66 TEST_F(GetLabelInfoTest, RootGenDir) { |
65 EXPECT_EQ("//out/Debug/gen", Call(":name", "root_gen_dir")); | 67 EXPECT_EQ("//out/Debug/gen", Call(":name", "root_gen_dir")); |
| 68 EXPECT_EQ("//out/Debug/gen", |
| 69 Call(":name(//toolchain:default)", "root_gen_dir")); |
66 EXPECT_EQ("//out/Debug/random/gen", | 70 EXPECT_EQ("//out/Debug/random/gen", |
67 Call(":name(//toolchain:random)", "root_gen_dir")); | 71 Call(":name(//toolchain:random)", "root_gen_dir")); |
68 } | 72 } |
69 | 73 |
70 TEST_F(GetLabelInfoTest, TargetOutDir) { | 74 TEST_F(GetLabelInfoTest, TargetOutDir) { |
71 EXPECT_EQ("//out/Debug/obj/src/foo", Call(":name", "target_out_dir")); | 75 EXPECT_EQ("//out/Debug/obj/src/foo", Call(":name", "target_out_dir")); |
72 EXPECT_EQ("//out/Debug", Call(":name", "root_out_dir")); | 76 EXPECT_EQ("//out/Debug", Call(":name", "root_out_dir")); |
| 77 |
| 78 EXPECT_EQ("//out/Debug/obj/foo", |
| 79 Call("//foo:name(//toolchain:default)", "target_out_dir")); |
| 80 EXPECT_EQ("//out/Debug/random/obj/foo", |
| 81 Call("//foo:name(//toolchain:random)", "target_out_dir")); |
73 } | 82 } |
74 | 83 |
75 TEST_F(GetLabelInfoTest, LabelNoToolchain) { | 84 TEST_F(GetLabelInfoTest, LabelNoToolchain) { |
76 EXPECT_EQ("//src/foo:name", Call(":name", "label_no_toolchain")); | 85 EXPECT_EQ("//src/foo:name", Call(":name", "label_no_toolchain")); |
77 EXPECT_EQ("//src/foo:name", | 86 EXPECT_EQ("//src/foo:name", |
78 Call("//src/foo:name(//toolchain:random)", "label_no_toolchain")); | 87 Call("//src/foo:name(//toolchain:random)", "label_no_toolchain")); |
79 } | 88 } |
80 | 89 |
81 TEST_F(GetLabelInfoTest, LabelWithToolchain) { | 90 TEST_F(GetLabelInfoTest, LabelWithToolchain) { |
82 EXPECT_EQ("//src/foo:name(//toolchain:default)", | 91 EXPECT_EQ("//src/foo:name(//toolchain:default)", |
83 Call(":name", "label_with_toolchain")); | 92 Call(":name", "label_with_toolchain")); |
84 EXPECT_EQ("//src/foo:name(//toolchain:random)", | 93 EXPECT_EQ("//src/foo:name(//toolchain:random)", |
85 Call(":name(//toolchain:random)", "label_with_toolchain")); | 94 Call(":name(//toolchain:random)", "label_with_toolchain")); |
86 } | 95 } |
87 | 96 |
88 TEST_F(GetLabelInfoTest, Toolchain) { | 97 TEST_F(GetLabelInfoTest, Toolchain) { |
89 EXPECT_EQ("//toolchain:default", Call(":name", "toolchain")); | 98 EXPECT_EQ("//toolchain:default", Call(":name", "toolchain")); |
90 EXPECT_EQ("//toolchain:random", | 99 EXPECT_EQ("//toolchain:random", |
91 Call(":name(//toolchain:random)", "toolchain")); | 100 Call(":name(//toolchain:random)", "toolchain")); |
92 } | 101 } |
OLD | NEW |