| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "tools/gn/functions.h" | 7 #include "tools/gn/functions.h" |
| 8 #include "tools/gn/parse_tree.h" | 8 #include "tools/gn/parse_tree.h" |
| 9 #include "tools/gn/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // Without a source root defined, we cannot move out of the source tree. | 45 // Without a source root defined, we cannot move out of the source tree. |
| 46 EXPECT_EQ("../..", RebaseOne(scope, "../../..", "//out/Debug", ".")); | 46 EXPECT_EQ("../..", RebaseOne(scope, "../../..", "//out/Debug", ".")); |
| 47 | 47 |
| 48 // Source-absolute input paths. | 48 // Source-absolute input paths. |
| 49 EXPECT_EQ("./", RebaseOne(scope, "//", "//", "//")); | 49 EXPECT_EQ("./", RebaseOne(scope, "//", "//", "//")); |
| 50 EXPECT_EQ("foo", RebaseOne(scope, "//foo", "//", "//")); | 50 EXPECT_EQ("foo", RebaseOne(scope, "//foo", "//", "//")); |
| 51 EXPECT_EQ("foo/", RebaseOne(scope, "//foo/", "//", "//")); | 51 EXPECT_EQ("foo/", RebaseOne(scope, "//foo/", "//", "//")); |
| 52 EXPECT_EQ("../../foo/bar", RebaseOne(scope, "//foo/bar", "//out/Debug", ".")); | 52 EXPECT_EQ("../../foo/bar", RebaseOne(scope, "//foo/bar", "//out/Debug", ".")); |
| 53 EXPECT_EQ("./", RebaseOne(scope, "//foo/", "//foo/", "//")); | 53 EXPECT_EQ("./", RebaseOne(scope, "//foo/", "//foo/", "//")); |
| 54 // Thie one is technically correct but could be simplified to "." if | 54 EXPECT_EQ(".", RebaseOne(scope, "//foo", "//foo", "//")); |
| 55 // necessary. | |
| 56 EXPECT_EQ("../foo", RebaseOne(scope, "//foo", "//foo", "//")); | |
| 57 | 55 |
| 58 // Test slash conversion. | 56 // Test slash conversion. |
| 59 EXPECT_EQ("foo/bar", RebaseOne(scope, "foo/bar", ".", ".")); | 57 EXPECT_EQ("foo/bar", RebaseOne(scope, "foo/bar", ".", ".")); |
| 60 EXPECT_EQ("foo/bar", RebaseOne(scope, "foo\\bar", ".", ".")); | 58 EXPECT_EQ("foo/bar", RebaseOne(scope, "foo\\bar", ".", ".")); |
| 61 | 59 |
| 62 // Test system path output. | 60 // Test system path output. |
| 63 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 64 setup.build_settings()->SetRootPath(base::FilePath(L"C:/path/to/src")); | 62 setup.build_settings()->SetRootPath(base::FilePath(L"C:/path/to/src")); |
| 65 EXPECT_EQ("C:/path/to/src", RebaseOne(scope, ".", "", "//")); | 63 EXPECT_EQ("C:/path/to/src", RebaseOne(scope, ".", "", "//")); |
| 66 EXPECT_EQ("C:/path/to/src/", RebaseOne(scope, "//", "", "//")); | 64 EXPECT_EQ("C:/path/to/src/", RebaseOne(scope, "//", "", "//")); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 TEST(RebasePath, Errors) { | 172 TEST(RebasePath, Errors) { |
| 175 TestWithScope setup; | 173 TestWithScope setup; |
| 176 | 174 |
| 177 // No arg input should issue an error. | 175 // No arg input should issue an error. |
| 178 Err err; | 176 Err err; |
| 179 std::vector<Value> args; | 177 std::vector<Value> args; |
| 180 FunctionCallNode function; | 178 FunctionCallNode function; |
| 181 Value ret = functions::RunRebasePath(setup.scope(), &function, args, &err); | 179 Value ret = functions::RunRebasePath(setup.scope(), &function, args, &err); |
| 182 EXPECT_TRUE(err.has_error()); | 180 EXPECT_TRUE(err.has_error()); |
| 183 } | 181 } |
| OLD | NEW |