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"
13 bool FormatFileToString(Setup
* setup
,
14 const SourceFile
& file
,
17 } // namespace commands
19 #define FORMAT_TEST(n) \
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, \
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")), \
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.
73 // TODO(scottmg): args+rebase_path unnecessarily split: FORMAT_TEST(034)
79 // TODO(scottmg): Bad break, exceeding 80 col: FORMAT_TEST(040)
83 // TODO(scottmg): Dewrapped caused exceeding 80 col: FORMAT_TEST(044)
88 // TODO(scottmg): Eval is broken (!) and comment output might have extra ,