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

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

Issue 1742303002: Accept absolute Windows paths without leading slash in GN commands (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/err.h" 9 #include "tools/gn/err.h"
10 #include "tools/gn/label_pattern.h" 10 #include "tools/gn/label_pattern.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Wildcards in invalid places. 51 // Wildcards in invalid places.
52 { "*foo*:bar", false, LabelPattern::MATCH, "", "", "" }, 52 { "*foo*:bar", false, LabelPattern::MATCH, "", "", "" },
53 { "foo*:*bar", false, LabelPattern::MATCH, "", "", "" }, 53 { "foo*:*bar", false, LabelPattern::MATCH, "", "", "" },
54 { "*foo:bar", false, LabelPattern::MATCH, "", "", "" }, 54 { "*foo:bar", false, LabelPattern::MATCH, "", "", "" },
55 { "foo:bar*", false, LabelPattern::MATCH, "", "", "" }, 55 { "foo:bar*", false, LabelPattern::MATCH, "", "", "" },
56 { "*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", "" }, 56 { "*:*", true, LabelPattern::RECURSIVE_DIRECTORY, "", "", "" },
57 // Invalid toolchain stuff. 57 // Invalid toolchain stuff.
58 { "//foo(//foo/bar:*)", false, LabelPattern::MATCH, "", "", "" }, 58 { "//foo(//foo/bar:*)", false, LabelPattern::MATCH, "", "", "" },
59 { "//foo/*(*)", false, LabelPattern::MATCH, "", "", "" }, 59 { "//foo/*(*)", false, LabelPattern::MATCH, "", "", "" },
60 { "//foo(//bar", false, LabelPattern::MATCH, "", "", "" }, 60 { "//foo(//bar", false, LabelPattern::MATCH, "", "", "" },
61 // Absolute paths.
62 { "/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/la/", "", "" },
63 { "/la:bar", true, LabelPattern::MATCH, "/la/", "bar", "" },
64 #if defined(OS_WIN)
65 { "/C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", "" },
66 { "C:/la/*", true, LabelPattern::RECURSIVE_DIRECTORY, "/C:/la/", "", "" },
67 { "/C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", "" },
68 { "C:/la:bar", true, LabelPattern::MATCH, "/C:/la/", "bar", "" },
69 #endif
61 }; 70 };
62 71
63 for (size_t i = 0; i < arraysize(cases); i++) { 72 for (size_t i = 0; i < arraysize(cases); i++) {
64 const PatternCase& cur = cases[i]; 73 const PatternCase& cur = cases[i];
65 Err err; 74 Err err;
66 LabelPattern result = 75 LabelPattern result =
67 LabelPattern::GetPattern(current_dir, Value(nullptr, cur.input), &err); 76 LabelPattern::GetPattern(current_dir, Value(nullptr, cur.input), &err);
68 77
69 EXPECT_EQ(cur.success, !err.has_error()) << i << " " << cur.input; 78 EXPECT_EQ(cur.success, !err.has_error()) << i << " " << cur.input;
70 EXPECT_EQ(cur.type, result.type()) << i << " " << cur.input; 79 EXPECT_EQ(cur.type, result.type()) << i << " " << cur.input;
71 EXPECT_EQ(cur.dir, result.dir().value()) << i << " " << cur.input; 80 EXPECT_EQ(cur.dir, result.dir().value()) << i << " " << cur.input;
72 EXPECT_EQ(cur.name, result.name()) << i << " " << cur.input; 81 EXPECT_EQ(cur.name, result.name()) << i << " " << cur.input;
73 EXPECT_EQ(cur.toolchain, result.toolchain().GetUserVisibleName(false)) 82 EXPECT_EQ(cur.toolchain, result.toolchain().GetUserVisibleName(false))
74 << i << " " << cur.input; 83 << i << " " << cur.input;
75 } 84 }
76 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698