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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d70e5a5713e4bea68d030bd83214e73a66ea7acf 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,23 @@ 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 src_dir; \
+ PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); \
+ 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
« 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