Repository: mesos Updated Branches: refs/heads/master 50d504931 -> 26cd5564d
Resolved the `realpath` of the sandbox directory in tests. This fixes test failures on systems (like macOS) where `/tmp` is a symlink. One such scenario is a test which makes a file in the sandbox, then makes a symlink to the file, and finally compares the realpath of the symlink to the file. If a part of the path of the original file in the sandbox is a symlink, this will cause the test to fail. The fact that the sandbox path is not a fully resolved file name is confusing. By instead getting the `realpath` of the sandbox during setup, we can fix the current test failures, and avoid future ones. Review: https://reviews.apache.org/r/66912/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/26cd5564 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/26cd5564 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/26cd5564 Branch: refs/heads/master Commit: 26cd5564dc2573d2a6c53632972883a595648b02 Parents: 50d5049 Author: Andrew Schwartzmeyer <[email protected]> Authored: Wed May 2 14:56:51 2018 -0700 Committer: Andrew Schwartzmeyer <[email protected]> Committed: Wed May 2 15:02:30 2018 -0700 ---------------------------------------------------------------------- 3rdparty/stout/include/stout/tests/utils.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/26cd5564/3rdparty/stout/include/stout/tests/utils.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/stout/include/stout/tests/utils.hpp b/3rdparty/stout/include/stout/tests/utils.hpp index bfbaa01..e7336a5 100644 --- a/3rdparty/stout/include/stout/tests/utils.hpp +++ b/3rdparty/stout/include/stout/tests/utils.hpp @@ -23,6 +23,7 @@ #include <stout/os/chdir.hpp> #include <stout/os/getcwd.hpp> #include <stout/os/mkdtemp.hpp> +#include <stout/os/realpath.hpp> #include <stout/os/rmdir.hpp> #if __FreeBSD__ @@ -39,10 +40,19 @@ protected: // Create a temporary directory for the test. Try<std::string> directory = os::mkdtemp(); - ASSERT_SOME(directory) << "Failed to mkdtemp"; - sandbox = directory.get(); + // We get the `realpath` of the temporary directory because some + // platforms, like macOS, symlink `/tmp` to `/private/var`, but + // return the symlink name when creating temporary directories. + // This is problematic because a lot of tests compare the + // `realpath` of a temporary file. + Result<std::string> realpath = os::realpath(directory.get()); + ASSERT_SOME(realpath) << "Failed to get realpath of '" << directory.get() + << "': " + << (realpath.isError() ? realpath.error() + : "No such directory"); + sandbox = realpath.get(); // Run the test out of the temporary directory we created. ASSERT_SOME(os::chdir(sandbox.get()))
