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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 EXPECT_EQ("//out/Debug/two/gen/", | 473 EXPECT_EQ("//out/Debug/two/gen/", |
474 GetToolchainGenDir(&build_settings, other_toolchain_label, | 474 GetToolchainGenDir(&build_settings, other_toolchain_label, |
475 false).value()); | 475 false).value()); |
476 } | 476 } |
477 | 477 |
478 TEST(FilesystemUtils, GetOutDirForSourceDir) { | 478 TEST(FilesystemUtils, GetOutDirForSourceDir) { |
479 BuildSettings build_settings; | 479 BuildSettings build_settings; |
480 build_settings.SetBuildDir(SourceDir("//out/Debug/")); | 480 build_settings.SetBuildDir(SourceDir("//out/Debug/")); |
481 | 481 |
482 // Test the default toolchain. | 482 // Test the default toolchain. |
| 483 Label default_toolchain_label(SourceDir("//toolchain/"), "default"); |
483 Settings default_settings(&build_settings, ""); | 484 Settings default_settings(&build_settings, ""); |
| 485 default_settings.set_toolchain_label(default_toolchain_label); |
| 486 default_settings.set_default_toolchain_label(default_toolchain_label); |
484 EXPECT_EQ("//out/Debug/obj/", | 487 EXPECT_EQ("//out/Debug/obj/", |
485 GetOutputDirForSourceDir( | 488 GetOutputDirForSourceDir( |
486 &default_settings, SourceDir("//")).value()); | 489 &default_settings, SourceDir("//")).value()); |
487 EXPECT_EQ("obj/", | 490 EXPECT_EQ("obj/", |
488 GetOutputDirForSourceDirAsOutputFile( | 491 GetOutputDirForSourceDirAsOutputFile( |
489 &default_settings, SourceDir("//")).value()); | 492 &default_settings, SourceDir("//")).value()); |
490 | 493 |
491 EXPECT_EQ("//out/Debug/obj/foo/bar/", | 494 EXPECT_EQ("//out/Debug/obj/foo/bar/", |
492 GetOutputDirForSourceDir( | 495 GetOutputDirForSourceDir( |
493 &default_settings, SourceDir("//foo/bar/")).value()); | 496 &default_settings, SourceDir("//foo/bar/")).value()); |
494 EXPECT_EQ("obj/foo/bar/", | 497 EXPECT_EQ("obj/foo/bar/", |
495 GetOutputDirForSourceDirAsOutputFile( | 498 GetOutputDirForSourceDirAsOutputFile( |
496 &default_settings, SourceDir("//foo/bar/")).value()); | 499 &default_settings, SourceDir("//foo/bar/")).value()); |
497 | 500 |
498 // Secondary toolchain. | 501 // Secondary toolchain. |
499 Settings other_settings(&build_settings, "two/"); | 502 Settings other_settings(&build_settings, "two/"); |
| 503 other_settings.set_toolchain_label(Label(SourceDir("//toolchain/"), "two")); |
| 504 other_settings.set_default_toolchain_label(default_toolchain_label); |
500 EXPECT_EQ("//out/Debug/two/obj/", | 505 EXPECT_EQ("//out/Debug/two/obj/", |
501 GetOutputDirForSourceDir( | 506 GetOutputDirForSourceDir( |
502 &other_settings, SourceDir("//")).value()); | 507 &other_settings, SourceDir("//")).value()); |
503 EXPECT_EQ("two/obj/", | 508 EXPECT_EQ("two/obj/", |
504 GetOutputDirForSourceDirAsOutputFile( | 509 GetOutputDirForSourceDirAsOutputFile( |
505 &other_settings, SourceDir("//")).value()); | 510 &other_settings, SourceDir("//")).value()); |
506 | 511 |
507 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", | 512 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", |
508 GetOutputDirForSourceDir(&other_settings, | 513 GetOutputDirForSourceDir(&other_settings, |
509 SourceDir("//foo/bar/")).value()); | 514 SourceDir("//foo/bar/")).value()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 EXPECT_EQ("gen/", GetToolchainGenDirAsOutputFile(&settings).value()); | 593 EXPECT_EQ("gen/", GetToolchainGenDirAsOutputFile(&settings).value()); |
589 EXPECT_EQ("//obj/", | 594 EXPECT_EQ("//obj/", |
590 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); | 595 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); |
591 EXPECT_EQ("obj/", | 596 EXPECT_EQ("obj/", |
592 GetOutputDirForSourceDirAsOutputFile( | 597 GetOutputDirForSourceDirAsOutputFile( |
593 &settings, SourceDir("//")).value()); | 598 &settings, SourceDir("//")).value()); |
594 EXPECT_EQ("gen/", | 599 EXPECT_EQ("gen/", |
595 GetGenDirForSourceDirAsOutputFile( | 600 GetGenDirForSourceDirAsOutputFile( |
596 &settings, SourceDir("//")).value()); | 601 &settings, SourceDir("//")).value()); |
597 } | 602 } |
OLD | NEW |