CMake/Tests/CMakeLib/testUVPatches.cxx
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00

48 lines
1.2 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#include <cmConfigure.h> // IWYU pragma: keep
#include <string>
#include <cm3p/uv.h>
#include "cmSystemTools.h"
#include "testCommon.h"
static bool test_uv_fs_mkdtemp()
{
std::cout << "test_uv_fs_mkdtemp()\n";
static std::string const kTemplate = "test-uv_fs_mkdtemp-XXXXXX";
std::string tempDir;
uv_fs_t tempDirReq;
tempDirReq.data = &tempDir;
uv_loop_t* loop = uv_default_loop();
int r =
uv_fs_mkdtemp(loop, &tempDirReq, kTemplate.c_str(), [](uv_fs_t* req) {
if (req->data && req->path) {
*static_cast<std::string*>(req->data) = req->path;
}
});
ASSERT_EQUAL(r, 0);
uv_run(loop, UV_RUN_DEFAULT);
uv_fs_req_cleanup(&tempDirReq);
uv_loop_close(loop);
if (!cmSystemTools::FileIsDirectory(tempDir)) {
std::cout << "cmSystemTools::MakeTempDirectory did not create \""
<< tempDir << '\n';
return false;
}
cmSystemTools::RemoveADirectory(tempDir);
ASSERT_TRUE(tempDir != kTemplate);
return true;
}
int testUVPatches(int /*unused*/, char* /*unused*/[])
{
return runTests({
test_uv_fs_mkdtemp,
});
}