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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
10 | 10 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 TEST(FilesystemUtils, GetToolchainDirs) { | 329 TEST(FilesystemUtils, GetToolchainDirs) { |
330 BuildSettings build_settings; | 330 BuildSettings build_settings; |
331 build_settings.SetBuildDir(SourceDir("//out/Debug/")); | 331 build_settings.SetBuildDir(SourceDir("//out/Debug/")); |
332 | 332 |
333 Settings default_settings(&build_settings, ""); | 333 Settings default_settings(&build_settings, ""); |
334 EXPECT_EQ("//out/Debug/", | 334 EXPECT_EQ("//out/Debug/", |
335 GetToolchainOutputDir(&default_settings).value()); | 335 GetToolchainOutputDir(&default_settings).value()); |
336 EXPECT_EQ("//out/Debug/gen/", | 336 EXPECT_EQ("//out/Debug/gen/", |
337 GetToolchainGenDir(&default_settings).value()); | 337 GetToolchainGenDir(&default_settings).value()); |
338 | 338 |
339 Settings other_settings(&build_settings, "two"); | 339 Settings other_settings(&build_settings, "two/"); |
340 EXPECT_EQ("//out/Debug/two/", | 340 EXPECT_EQ("//out/Debug/two/", |
341 GetToolchainOutputDir(&other_settings).value()); | 341 GetToolchainOutputDir(&other_settings).value()); |
342 EXPECT_EQ("//out/Debug/two/gen/", | 342 EXPECT_EQ("//out/Debug/two/gen/", |
343 GetToolchainGenDir(&other_settings).value()); | 343 GetToolchainGenDir(&other_settings).value()); |
344 } | 344 } |
345 | 345 |
346 TEST(FilesystemUtils, GetOutDirForSourceDir) { | 346 TEST(FilesystemUtils, GetOutDirForSourceDir) { |
347 BuildSettings build_settings; | 347 BuildSettings build_settings; |
348 build_settings.SetBuildDir(SourceDir("//out/Debug/")); | 348 build_settings.SetBuildDir(SourceDir("//out/Debug/")); |
349 | 349 |
350 // Test the default toolchain. | 350 // Test the default toolchain. |
351 Settings default_settings(&build_settings, ""); | 351 Settings default_settings(&build_settings, ""); |
352 EXPECT_EQ("//out/Debug/obj/", | 352 EXPECT_EQ("//out/Debug/obj/", |
353 GetOutputDirForSourceDir(&default_settings, | 353 GetOutputDirForSourceDir(&default_settings, |
354 SourceDir("//")).value()); | 354 SourceDir("//")).value()); |
355 EXPECT_EQ("//out/Debug/obj/foo/bar/", | 355 EXPECT_EQ("//out/Debug/obj/foo/bar/", |
356 GetOutputDirForSourceDir(&default_settings, | 356 GetOutputDirForSourceDir(&default_settings, |
357 SourceDir("//foo/bar/")).value()); | 357 SourceDir("//foo/bar/")).value()); |
358 | 358 |
359 // Secondary toolchain. | 359 // Secondary toolchain. |
360 Settings other_settings(&build_settings, "two"); | 360 Settings other_settings(&build_settings, "two/"); |
361 EXPECT_EQ("//out/Debug/two/obj/", | 361 EXPECT_EQ("//out/Debug/two/obj/", |
362 GetOutputDirForSourceDir(&other_settings, SourceDir("//")).value()); | 362 GetOutputDirForSourceDir(&other_settings, SourceDir("//")).value()); |
363 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", | 363 EXPECT_EQ("//out/Debug/two/obj/foo/bar/", |
364 GetOutputDirForSourceDir(&other_settings, | 364 GetOutputDirForSourceDir(&other_settings, |
365 SourceDir("//foo/bar/")).value()); | 365 SourceDir("//foo/bar/")).value()); |
366 } | 366 } |
367 | 367 |
368 TEST(FilesystemUtils, GetGenDirForSourceDir) { | 368 TEST(FilesystemUtils, GetGenDirForSourceDir) { |
369 BuildSettings build_settings; | 369 BuildSettings build_settings; |
370 build_settings.SetBuildDir(SourceDir("//out/Debug/")); | 370 build_settings.SetBuildDir(SourceDir("//out/Debug/")); |
371 | 371 |
372 // Test the default toolchain. | 372 // Test the default toolchain. |
373 Settings default_settings(&build_settings, ""); | 373 Settings default_settings(&build_settings, ""); |
374 EXPECT_EQ("//out/Debug/gen/", | 374 EXPECT_EQ("//out/Debug/gen/", |
375 GetGenDirForSourceDir(&default_settings, SourceDir("//")).value()); | 375 GetGenDirForSourceDir(&default_settings, SourceDir("//")).value()); |
376 EXPECT_EQ("//out/Debug/gen/foo/bar/", | 376 EXPECT_EQ("//out/Debug/gen/foo/bar/", |
377 GetGenDirForSourceDir(&default_settings, | 377 GetGenDirForSourceDir(&default_settings, |
378 SourceDir("//foo/bar/")).value()); | 378 SourceDir("//foo/bar/")).value()); |
379 | 379 |
380 // Secondary toolchain. | 380 // Secondary toolchain. |
381 Settings other_settings(&build_settings, "two"); | 381 Settings other_settings(&build_settings, "two/"); |
382 EXPECT_EQ("//out/Debug/two/gen/", | 382 EXPECT_EQ("//out/Debug/two/gen/", |
383 GetGenDirForSourceDir(&other_settings, SourceDir("//")).value()); | 383 GetGenDirForSourceDir(&other_settings, SourceDir("//")).value()); |
384 EXPECT_EQ("//out/Debug/two/gen/foo/bar/", | 384 EXPECT_EQ("//out/Debug/two/gen/foo/bar/", |
385 GetGenDirForSourceDir(&other_settings, | 385 GetGenDirForSourceDir(&other_settings, |
386 SourceDir("//foo/bar/")).value()); | 386 SourceDir("//foo/bar/")).value()); |
387 } | 387 } |
388 | 388 |
389 // Tests handling of output dirs when build dir is the same as the root. | 389 // Tests handling of output dirs when build dir is the same as the root. |
390 TEST(FilesystemUtils, GetDirForEmptyBuildDir) { | 390 TEST(FilesystemUtils, GetDirForEmptyBuildDir) { |
391 BuildSettings build_settings; | 391 BuildSettings build_settings; |
392 build_settings.SetBuildDir(SourceDir("//")); | 392 build_settings.SetBuildDir(SourceDir("//")); |
393 Settings settings(&build_settings, ""); | 393 Settings settings(&build_settings, ""); |
394 | 394 |
395 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value()); | 395 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value()); |
396 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value()); | 396 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value()); |
397 EXPECT_EQ("//obj/", | 397 EXPECT_EQ("//obj/", |
398 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); | 398 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); |
399 EXPECT_EQ("//gen/", | 399 EXPECT_EQ("//gen/", |
400 GetGenDirForSourceDir(&settings, SourceDir("//")).value()); | 400 GetGenDirForSourceDir(&settings, SourceDir("//")).value()); |
401 } | 401 } |
OLD | NEW |