* Changing crash report limitation logic to have more control over extreme cases.
[chromium-blink-merge.git] / tools / gn / command_format_unittest.cc
blobe0f6816a50c66d4e536688a49a495c5fa6c7f0a6
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
3 // found in the LICENSE file.
5 #include "base/files/file_util.h"
6 #include "base/path_service.h"
7 #include "base/strings/string_util.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/gn/commands.h"
10 #include "tools/gn/setup.h"
12 namespace commands {
13 bool FormatFileToString(Setup* setup,
14 const SourceFile& file,
15 bool dump_tree,
16 std::string* output);
17 } // namespace commands
19 #define FORMAT_TEST(n) \
20 TEST(Format, n) { \
21 ::Setup setup; \
22 std::string out; \
23 std::string expected; \
24 base::FilePath src_dir; \
25 PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); \
26 base::SetCurrentDirectory(src_dir); \
27 EXPECT_TRUE(commands::FormatFileToString( \
28 &setup, SourceFile("//tools/gn/format_test_data/" #n ".gn"), false, \
29 &out)); \
30 ASSERT_TRUE(base::ReadFileToString( \
31 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \
32 FILE_PATH_LITERAL(#n) \
33 FILE_PATH_LITERAL(".golden")), \
34 &expected)); \
35 EXPECT_EQ(expected, out); \
38 // These are expanded out this way rather than a runtime loop so that
39 // --gtest_filter works as expected for individual test running.
40 FORMAT_TEST(001)
41 FORMAT_TEST(002)
42 FORMAT_TEST(003)
43 FORMAT_TEST(004)
44 FORMAT_TEST(005)
45 FORMAT_TEST(006)
46 FORMAT_TEST(007)
47 FORMAT_TEST(008)
48 FORMAT_TEST(009)
49 FORMAT_TEST(010)
50 FORMAT_TEST(011)
51 FORMAT_TEST(012)
52 FORMAT_TEST(013)
53 FORMAT_TEST(014)
54 FORMAT_TEST(015)
55 FORMAT_TEST(016)
56 FORMAT_TEST(017)
57 FORMAT_TEST(018)
58 FORMAT_TEST(019)
59 FORMAT_TEST(020)
60 FORMAT_TEST(021)
61 FORMAT_TEST(022)
62 FORMAT_TEST(023)
63 FORMAT_TEST(024)
64 FORMAT_TEST(025)
65 FORMAT_TEST(026)
66 FORMAT_TEST(027)
67 FORMAT_TEST(028)
68 FORMAT_TEST(029)
69 FORMAT_TEST(030)
70 FORMAT_TEST(031)
71 FORMAT_TEST(032)
72 FORMAT_TEST(033)
73 // TODO(scottmg): args+rebase_path unnecessarily split: FORMAT_TEST(034)
74 FORMAT_TEST(035)
75 FORMAT_TEST(036)
76 FORMAT_TEST(037)
77 FORMAT_TEST(038)
78 FORMAT_TEST(039)
79 // TODO(scottmg): Bad break, exceeding 80 col: FORMAT_TEST(040)
80 FORMAT_TEST(041)
81 FORMAT_TEST(042)
82 FORMAT_TEST(043)
83 // TODO(scottmg): Dewrapped caused exceeding 80 col: FORMAT_TEST(044)
84 FORMAT_TEST(045)
85 FORMAT_TEST(046)
86 FORMAT_TEST(047)
87 FORMAT_TEST(048)
88 // TODO(scottmg): Eval is broken (!) and comment output might have extra ,
89 // FORMAT_TEST(049)
90 FORMAT_TEST(050)
91 FORMAT_TEST(051)
92 FORMAT_TEST(052)
93 FORMAT_TEST(053)
94 FORMAT_TEST(054)
95 FORMAT_TEST(055)
96 FORMAT_TEST(056)
97 FORMAT_TEST(057)
98 FORMAT_TEST(058)
99 FORMAT_TEST(059)
100 FORMAT_TEST(060)
101 FORMAT_TEST(061)
102 FORMAT_TEST(062)