Chromium Code Reviews| Index: tools/gn/command_format_unittest.cc |
| diff --git a/tools/gn/command_format_unittest.cc b/tools/gn/command_format_unittest.cc |
| index 1b1c08e4d3da27290308fcee3648bf61a6cad0f8..5ed7c5c47ea3c8669c2f127f62875a0d28731052 100644 |
| --- a/tools/gn/command_format_unittest.cc |
| +++ b/tools/gn/command_format_unittest.cc |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/files/file_util.h" |
| +#include "base/path_service.h" |
| #include "base/strings/string_util.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "tools/gn/commands.h" |
| @@ -15,22 +16,24 @@ bool FormatFileToString(Setup* setup, |
| std::string* output); |
| } // namespace commands |
| -#define FORMAT_TEST(n) \ |
| - TEST(Format, n) { \ |
| - ::Setup setup; \ |
| - std::string out; \ |
| - std::string expected; \ |
| - EXPECT_TRUE(commands::FormatFileToString( \ |
| - &setup, \ |
| - SourceFile("//tools/gn/format_test_data/" #n ".gn"), \ |
| - false, \ |
| - &out)); \ |
| - ASSERT_TRUE(base::ReadFileToString( \ |
| - base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \ |
| - FILE_PATH_LITERAL(#n) \ |
| - FILE_PATH_LITERAL(".golden")), \ |
| - &expected)); \ |
| - EXPECT_EQ(expected, out); \ |
| +#define FORMAT_TEST(n) \ |
| + TEST(Format, n) { \ |
| + ::Setup setup; \ |
| + std::string out; \ |
| + std::string expected; \ |
| + base::FilePath exe; \ |
| + PathService::Get(base::FILE_EXE, &exe); \ |
|
Dirk Pranke
2014/12/19 18:24:39
Can you use PathService::Get(base::DIR_SOURCE_ROOT
tfarina
2014/12/19 18:29:04
+1 for that. I found DIR_SOURCE_ROOT easier to und
scottmg
2014/12/19 18:31:45
Ah, indeed. Done.
(Sadly, it's doing the same thi
|
| + base::FilePath src_dir = exe.DirName().DirName().DirName(); \ |
| + base::SetCurrentDirectory(src_dir); \ |
| + EXPECT_TRUE(commands::FormatFileToString( \ |
| + &setup, SourceFile("//tools/gn/format_test_data/" #n ".gn"), false, \ |
| + &out)); \ |
| + ASSERT_TRUE(base::ReadFileToString( \ |
| + base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \ |
| + FILE_PATH_LITERAL(#n) \ |
| + FILE_PATH_LITERAL(".golden")), \ |
| + &expected)); \ |
| + EXPECT_EQ(expected, out); \ |
| } |
| // These are expanded out this way rather than a runtime loop so that |