forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_runfiles_test.cc
46 lines (37 loc) · 1.36 KB
/
find_runfiles_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "drake/common/find_runfiles.h"
#include <filesystem>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "drake/common/temp_directory.h"
#include "drake/common/test_utilities/expect_throws_message.h"
#include "drake/common/text_logging.h"
namespace drake {
namespace {
GTEST_TEST(FindRunfilesTest, AcceptanceTest) {
EXPECT_TRUE(HasRunfiles());
const auto result = FindRunfile(
"drake/common/test/find_resource_test_data.txt");
drake::log()->debug("result.abspath: {}", result.abspath);
EXPECT_GT(result.abspath.size(), 0);
EXPECT_TRUE(std::filesystem::is_regular_file({result.abspath}));
EXPECT_EQ(result.error, "");
}
GTEST_TEST(FindRunfilesTest, NotDeclaredTest) {
const auto result = FindRunfile("foo");
EXPECT_THAT(result.error, testing::MatchesRegex(
"Sought 'foo' in runfiles directory '.*' but "
"the file does not exist at that location nor is it on the "
"manifest; perhaps a 'data = ..' dependency is missing."));
};
GTEST_TEST(FindRunfilesTest, AbsolutePathTest) {
const auto result = FindRunfile("/dev/null");
EXPECT_THAT(result.error, testing::MatchesRegex(
".*must not be an absolute path.*"));
};
GTEST_TEST(FindRunfilesTest, EmptyPathTest) {
const auto result = FindRunfile("");
EXPECT_THAT(result.error, testing::MatchesRegex(
".*must not be empty.*"));
};
} // namespace
} // namespace drake