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

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

Issue 613083003: gn format: support absolute file system paths (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: help Created 6 years, 2 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 "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/commands.h" 8 #include "tools/gn/commands.h"
9 #include "tools/gn/setup.h"
9 10
10 namespace commands { 11 namespace commands {
11 bool FormatFileToString(const std::string& input_filename, 12 bool FormatFileToString(Setup* setup,
13 const SourceFile& file,
12 bool dump_tree, 14 bool dump_tree,
13 std::string* output); 15 std::string* output);
14 } // namespace commands 16 } // namespace commands
15 17
16 #define FORMAT_TEST(n) \ 18 #define FORMAT_TEST(n) \
17 TEST(Format, n) { \ 19 TEST(Format, n) { \
20 ::Setup setup; \
18 std::string out; \ 21 std::string out; \
19 std::string expected; \ 22 std::string expected; \
20 EXPECT_TRUE(commands::FormatFileToString( \ 23 EXPECT_TRUE(commands::FormatFileToString( \
21 "//tools/gn/format_test_data/" #n ".gn", false, &out)); \ 24 &setup, \
25 SourceFile("//tools/gn/format_test_data/" #n ".gn"), \
26 false, \
27 &out)); \
22 ASSERT_TRUE(base::ReadFileToString( \ 28 ASSERT_TRUE(base::ReadFileToString( \
23 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \ 29 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \
24 FILE_PATH_LITERAL(#n) \ 30 FILE_PATH_LITERAL(#n) \
25 FILE_PATH_LITERAL(".golden")), \ 31 FILE_PATH_LITERAL(".golden")), \
26 &expected)); \ 32 &expected)); \
27 EXPECT_EQ(expected, out); \ 33 EXPECT_EQ(expected, out); \
28 } 34 }
29 35
30 // These are expanded out this way rather than a runtime loop so that 36 // These are expanded out this way rather than a runtime loop so that
31 // --gtest_filter works as expected for individual test running. 37 // --gtest_filter works as expected for individual test running.
(...skipping 12 matching lines...) Expand all
44 FORMAT_TEST(013) 50 FORMAT_TEST(013)
45 FORMAT_TEST(014) 51 FORMAT_TEST(014)
46 FORMAT_TEST(015) 52 FORMAT_TEST(015)
47 // TODO(scottmg): Requires precedence/parentheses FORMAT_TEST(016) 53 // TODO(scottmg): Requires precedence/parentheses FORMAT_TEST(016)
48 FORMAT_TEST(017) 54 FORMAT_TEST(017)
49 FORMAT_TEST(018) 55 FORMAT_TEST(018)
50 FORMAT_TEST(019) 56 FORMAT_TEST(019)
51 FORMAT_TEST(020) 57 FORMAT_TEST(020)
52 FORMAT_TEST(021) 58 FORMAT_TEST(021)
53 FORMAT_TEST(022) 59 FORMAT_TEST(022)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698