OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "tools/gn/filesystem_utils.h" | 10 #include "tools/gn/filesystem_utils.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 EXPECT_EQ("two/obj/", | 498 EXPECT_EQ("two/obj/", |
499 GetOutputDirForSourceDirAsOutputFile( | 499 GetOutputDirForSourceDirAsOutputFile( |
500 &other_settings, SourceDir("//")).value()); | 500 &other_settings, SourceDir("//")).value()); |
501 | 501 |
502 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", | 502 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", |
503 GetOutputDirForSourceDir(&other_settings, | 503 GetOutputDirForSourceDir(&other_settings, |
504 SourceDir("//foo/bar/")).value()); | 504 SourceDir("//foo/bar/")).value()); |
505 EXPECT_EQ("two/obj/foo/bar/", | 505 EXPECT_EQ("two/obj/foo/bar/", |
506 GetOutputDirForSourceDirAsOutputFile( | 506 GetOutputDirForSourceDirAsOutputFile( |
507 &other_settings, SourceDir("//foo/bar/")).value()); | 507 &other_settings, SourceDir("//foo/bar/")).value()); |
| 508 |
| 509 // Absolute source path |
| 510 EXPECT_EQ("//out/Debug/obj/ABS_PATH/abs/", |
| 511 GetOutputDirForSourceDir( |
| 512 &default_settings, SourceDir("/abs")).value()); |
| 513 EXPECT_EQ("obj/ABS_PATH/abs/", |
| 514 GetOutputDirForSourceDirAsOutputFile( |
| 515 &default_settings, SourceDir("/abs")).value()); |
| 516 #if defined(OS_WIN) |
| 517 EXPECT_EQ("//out/Debug/obj/ABS_PATH/C/abs/", |
| 518 GetOutputDirForSourceDir( |
| 519 &default_settings, SourceDir("/C:/abs")).value()); |
| 520 EXPECT_EQ("obj/ABS_PATH/C/abs/", |
| 521 GetOutputDirForSourceDirAsOutputFile( |
| 522 &default_settings, SourceDir("/C:/abs")).value()); |
| 523 #endif |
508 } | 524 } |
509 | 525 |
510 TEST(FilesystemUtils, GetGenDirForSourceDir) { | 526 TEST(FilesystemUtils, GetGenDirForSourceDir) { |
511 BuildSettings build_settings; | 527 BuildSettings build_settings; |
512 build_settings.SetBuildDir(SourceDir("//out/Debug/")); | 528 build_settings.SetBuildDir(SourceDir("//out/Debug/")); |
513 | 529 |
514 // Test the default toolchain. | 530 // Test the default toolchain. |
515 Settings default_settings(&build_settings, ""); | 531 Settings default_settings(&build_settings, ""); |
516 EXPECT_EQ("//out/Debug/gen/", | 532 EXPECT_EQ("//out/Debug/gen/", |
517 GetGenDirForSourceDir( | 533 GetGenDirForSourceDir( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 EXPECT_EQ("gen/", GetToolchainGenDirAsOutputFile(&settings).value()); | 583 EXPECT_EQ("gen/", GetToolchainGenDirAsOutputFile(&settings).value()); |
568 EXPECT_EQ("//obj/", | 584 EXPECT_EQ("//obj/", |
569 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); | 585 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); |
570 EXPECT_EQ("obj/", | 586 EXPECT_EQ("obj/", |
571 GetOutputDirForSourceDirAsOutputFile( | 587 GetOutputDirForSourceDirAsOutputFile( |
572 &settings, SourceDir("//")).value()); | 588 &settings, SourceDir("//")).value()); |
573 EXPECT_EQ("gen/", | 589 EXPECT_EQ("gen/", |
574 GetGenDirForSourceDirAsOutputFile( | 590 GetGenDirForSourceDirAsOutputFile( |
575 &settings, SourceDir("//")).value()); | 591 &settings, SourceDir("//")).value()); |
576 } | 592 } |
OLD | NEW |