MCPcopy Create free account
hub / github.com/apache/mesos / createTestFile

Method createTestFile

src/tests/common/command_utils_tests.cpp:44–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42{
43protected:
44 Try<Nothing> createTestFile(
45 const Path& file,
46 const Option<Path>& directory = None())
47 {
48 const Path testFile(
49 directory.isSome() ?
50 path::join(directory.get(), file.string()): file);
51
52 const string& testFileDir = testFile.dirname();
53 if (!os::exists(testFileDir)) {
54 Try<Nothing> mkdir = os::mkdir(testFileDir, true);
55 if (mkdir.isError()) {
56 return Error("Failed to create test directory: " + mkdir.error());
57 }
58 }
59
60 Try<Nothing> write = os::write(testFile, "test");
61 if (write.isError()) {
62 return Error("Failed to create to test file: " + write.error());
63 }
64
65 return Nothing();
66 }
67};
68
69

Callers

nothing calls this directly

Calls 13

NoneClass · 0.85
NothingClass · 0.85
dirnameMethod · 0.80
errorMethod · 0.65
joinFunction · 0.50
existsFunction · 0.50
mkdirFunction · 0.50
ErrorFunction · 0.50
writeFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected