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

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

Issue 711113004: original (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win compile fix Created 6 years, 1 month 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/function_rebase_path.cc ('k') | tools/gn/function_write_file.cc » ('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 "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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #else 71 #else
72 setup.build_settings()->SetRootPath(base::FilePath("/source")); 72 setup.build_settings()->SetRootPath(base::FilePath("/source"));
73 EXPECT_EQ("/source", RebaseOne(scope, ".", "", "//")); 73 EXPECT_EQ("/source", RebaseOne(scope, ".", "", "//"));
74 EXPECT_EQ("/source/", RebaseOne(scope, "//", "", "//")); 74 EXPECT_EQ("/source/", RebaseOne(scope, "//", "", "//"));
75 EXPECT_EQ("/source/foo", RebaseOne(scope, "foo", "", "//")); 75 EXPECT_EQ("/source/foo", RebaseOne(scope, "foo", "", "//"));
76 EXPECT_EQ("/source/foo/", RebaseOne(scope, "foo/", "", "//")); 76 EXPECT_EQ("/source/foo/", RebaseOne(scope, "foo/", "", "//"));
77 EXPECT_EQ("/source/tools/gn/foo", RebaseOne(scope, "foo", "", ".")); 77 EXPECT_EQ("/source/tools/gn/foo", RebaseOne(scope, "foo", "", "."));
78 #endif 78 #endif
79 } 79 }
80 80
81 TEST(RebasePath, StringsSystemPaths) {
82 TestWithScope setup;
83 Scope* scope = setup.scope();
84 setup.build_settings()->SetBuildDir(SourceDir("/ssd/out/Debug"));
85 setup.build_settings()->SetRootPath(base::FilePath("/hdd/src"));
86
87 // Test system absolute to-dir.
88 EXPECT_EQ("../../ssd/out/Debug",
89 RebaseOne(scope, ".", "//", "/ssd/out/Debug"));
90 EXPECT_EQ("../../ssd/out/Debug/",
91 RebaseOne(scope, "./", "//", "/ssd/out/Debug"));
92 EXPECT_EQ("../../ssd/out/Debug/foo",
93 RebaseOne(scope, "foo", "//", "/ssd/out/Debug"));
94 EXPECT_EQ("../../ssd/out/Debug/foo/",
95 RebaseOne(scope, "foo/", "//", "/ssd/out/Debug"));
96
97 // Test system absolute from-dir.
98 EXPECT_EQ("../../../hdd/src",
99 RebaseOne(scope, ".", "/ssd/out/Debug", "//"));
100 EXPECT_EQ("../../../hdd/src/",
101 RebaseOne(scope, "./", "/ssd/out/Debug", "//"));
102 EXPECT_EQ("../../../hdd/src/foo",
103 RebaseOne(scope, "foo", "/ssd/out/Debug", "//"));
104 EXPECT_EQ("../../../hdd/src/foo/",
105 RebaseOne(scope, "foo/", "/ssd/out/Debug", "//"));
106 }
107
81 // Test list input. 108 // Test list input.
82 TEST(RebasePath, List) { 109 TEST(RebasePath, List) {
83 TestWithScope setup; 110 TestWithScope setup;
84 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 111 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
85 setup.scope()->set_source_dir(SourceDir("//tools/gn/")); 112 setup.scope()->set_source_dir(SourceDir("//tools/gn/"));
86 113
87 std::vector<Value> args; 114 std::vector<Value> args;
88 args.push_back(Value(NULL, Value::LIST)); 115 args.push_back(Value(NULL, Value::LIST));
89 args[0].list_value().push_back(Value(NULL, "foo.txt")); 116 args[0].list_value().push_back(Value(NULL, "foo.txt"));
90 args[0].list_value().push_back(Value(NULL, "bar.txt")); 117 args[0].list_value().push_back(Value(NULL, "bar.txt"));
(...skipping 16 matching lines...) Expand all
107 TestWithScope setup; 134 TestWithScope setup;
108 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 135 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
109 136
110 // No arg input should issue an error. 137 // No arg input should issue an error.
111 Err err; 138 Err err;
112 std::vector<Value> args; 139 std::vector<Value> args;
113 FunctionCallNode function; 140 FunctionCallNode function;
114 Value ret = functions::RunRebasePath(setup.scope(), &function, args, &err); 141 Value ret = functions::RunRebasePath(setup.scope(), &function, args, &err);
115 EXPECT_TRUE(err.has_error()); 142 EXPECT_TRUE(err.has_error());
116 } 143 }
OLDNEW
« no previous file with comments | « tools/gn/function_rebase_path.cc ('k') | tools/gn/function_write_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698