[test] Fix SetupTest.AbsolutePythonPathInsideRootDir on macOS The test was failing because it was comparing a path containing symlinks (e.g., /var/folders/...) with a resolved realpath (e.g., /private/var/folders/...). GN's Setup resolves the source root to its realpath, so the test needs to do the same for the temp directory it creates. Bug: None Change-Id: I25bcb19e605eb580e5ac72f30646d90654b97665 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/21020 Reviewed-by: David Turner <digit@google.com> Commit-Queue: David Turner <digit@google.com>
diff --git a/src/gn/setup_unittest.cc b/src/gn/setup_unittest.cc index 547c282..3140e52 100644 --- a/src/gn/setup_unittest.cc +++ b/src/gn/setup_unittest.cc
@@ -28,7 +28,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, "buildconfig = \"//BUILDCONFIG.gn\"\n"); WriteFile(in_path.Append(FILE_PATH_LITERAL("BUILDCONFIG.gn")), ""); @@ -59,7 +59,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -90,7 +90,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -119,7 +119,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, "buildconfig = \"//BUILDCONFIG.gn\"\n\ @@ -168,7 +168,7 @@ // Create a temp directory containing the build. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -210,7 +210,7 @@ // Create a temp directory containing the build. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); WriteFile(in_path.Append(FILE_PATH_LITERAL("BUILDCONFIG.gn")), ""); WriteFile(in_path.Append(FILE_PATH_LITERAL(".gn")), kDotfileContents); @@ -245,7 +245,7 @@ // Create a temp directory containing the build. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); WriteFile(in_path.Append(FILE_PATH_LITERAL("BUILDCONFIG.gn")), ""); WriteFile(in_path.Append(FILE_PATH_LITERAL(".gn")), kDotfileContents); @@ -310,7 +310,7 @@ // Create a temp directory containing the build. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); WriteFile(in_path.Append(FILE_PATH_LITERAL("BUILD.gn")), kBuildGnContents); WriteFile(in_path.Append(FILE_PATH_LITERAL("BUILDCONFIG.gn")), @@ -373,7 +373,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -423,7 +423,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -460,7 +460,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents); @@ -500,7 +500,7 @@ // pass it as --root. base::ScopedTempDir in_temp_dir; ASSERT_TRUE(in_temp_dir.CreateUniqueTempDir()); - base::FilePath in_path = in_temp_dir.GetPath(); + base::FilePath in_path = base::MakeAbsoluteFilePath(in_temp_dir.GetPath()); base::FilePath dot_gn_name = in_path.Append(FILE_PATH_LITERAL(".gn")); WriteFile(dot_gn_name, kDotfileContents);