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

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

Issue 818623002: Make running gn format unittests from anywhere work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dir_source_root Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/path_service.h"
6 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/commands.h" 9 #include "tools/gn/commands.h"
9 #include "tools/gn/setup.h" 10 #include "tools/gn/setup.h"
10 11
11 namespace commands { 12 namespace commands {
12 bool FormatFileToString(Setup* setup, 13 bool FormatFileToString(Setup* setup,
13 const SourceFile& file, 14 const SourceFile& file,
14 bool dump_tree, 15 bool dump_tree,
15 std::string* output); 16 std::string* output);
16 } // namespace commands 17 } // namespace commands
17 18
18 #define FORMAT_TEST(n) \ 19 #define FORMAT_TEST(n) \
19 TEST(Format, n) { \ 20 TEST(Format, n) { \
20 ::Setup setup; \ 21 ::Setup setup; \
21 std::string out; \ 22 std::string out; \
22 std::string expected; \ 23 std::string expected; \
23 EXPECT_TRUE(commands::FormatFileToString( \ 24 base::FilePath src_dir; \
24 &setup, \ 25 PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); \
25 SourceFile("//tools/gn/format_test_data/" #n ".gn"), \ 26 base::SetCurrentDirectory(src_dir); \
26 false, \ 27 EXPECT_TRUE(commands::FormatFileToString( \
27 &out)); \ 28 &setup, SourceFile("//tools/gn/format_test_data/" #n ".gn"), false, \
28 ASSERT_TRUE(base::ReadFileToString( \ 29 &out)); \
29 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \ 30 ASSERT_TRUE(base::ReadFileToString( \
30 FILE_PATH_LITERAL(#n) \ 31 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \
31 FILE_PATH_LITERAL(".golden")), \ 32 FILE_PATH_LITERAL(#n) \
32 &expected)); \ 33 FILE_PATH_LITERAL(".golden")), \
33 EXPECT_EQ(expected, out); \ 34 &expected)); \
35 EXPECT_EQ(expected, out); \
34 } 36 }
35 37
36 // These are expanded out this way rather than a runtime loop so that 38 // These are expanded out this way rather than a runtime loop so that
37 // --gtest_filter works as expected for individual test running. 39 // --gtest_filter works as expected for individual test running.
38 FORMAT_TEST(001) 40 FORMAT_TEST(001)
39 FORMAT_TEST(002) 41 FORMAT_TEST(002)
40 FORMAT_TEST(003) 42 FORMAT_TEST(003)
41 FORMAT_TEST(004) 43 FORMAT_TEST(004)
42 FORMAT_TEST(005) 44 FORMAT_TEST(005)
43 FORMAT_TEST(006) 45 FORMAT_TEST(006)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 FORMAT_TEST(052) 92 FORMAT_TEST(052)
91 FORMAT_TEST(053) 93 FORMAT_TEST(053)
92 FORMAT_TEST(054) 94 FORMAT_TEST(054)
93 FORMAT_TEST(055) 95 FORMAT_TEST(055)
94 FORMAT_TEST(056) 96 FORMAT_TEST(056)
95 FORMAT_TEST(057) 97 FORMAT_TEST(057)
96 FORMAT_TEST(058) 98 FORMAT_TEST(058)
97 FORMAT_TEST(059) 99 FORMAT_TEST(059)
98 FORMAT_TEST(060) 100 FORMAT_TEST(060)
99 FORMAT_TEST(061) 101 FORMAT_TEST(061)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698