Fixed Windows build and tests

* tl::is_same_file works with directories now too
* Unit tests added for this
* bridge_mod sample produces the proper DLL now
This commit is contained in:
klayoutmatthias 2018-07-15 18:03:42 +02:00
parent bbb88c5ca6
commit 6858190a20
4 changed files with 48 additions and 4 deletions

View File

@ -91,9 +91,11 @@ win32 {
# to avoid the major version being appended to the dll name - in this case -lxyz won't link it again
# because the library is called xyx0.dll.
CONFIG += skip_target_version_ext
# make the proper library name for Python
QMAKE_POST_LINK += $(COPY) $(DESTDIR_TARGET) $$DESTDIR/$${TARGET}$${PYTHONEXTSUFFIX}
} else {
# Make the target library without the "lib" prefix on Linux
QMAKE_POST_LINK += $(COPY) $(DESTDIR)$(TARGET) $$DESTDIR/$${TARGET}.so
QMAKE_POST_LINK += $(COPY) $(DESTDIR)$(TARGET) $$DESTDIR/$${TARGET}$${PYTHONEXTSUFFIX}
}
# nothing to install as we're building a test library

View File

@ -39,6 +39,7 @@ int run_pymodtest (tl::TestBase *_this, const std::string &fn)
pypath = "PYTHONPATH=";
pypath += STRINGIFY (PYTHONPATH);
putenv ((char *) pypath.c_str ());
tl::info << pypath;
std::string fp (tl::testsrc ());
fp += "/testdata/pymod/";

View File

@ -713,8 +713,8 @@ bool is_same_file (const std::string &a, const std::string &b)
#if defined(_WIN32)
HANDLE h1 = ::CreateFileW (tl::to_wstring (a).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE h2 = ::CreateFileW (tl::to_wstring (b).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE h1 = ::CreateFileW (tl::to_wstring (a).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
HANDLE h2 = ::CreateFileW (tl::to_wstring (b).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
bool result = false;

View File

@ -24,6 +24,7 @@
#include "tlFileUtils.h"
#include "tlUnitTest.h"
#include "tlStream.h"
#include "tlString.h"
#include <fstream>
@ -540,7 +541,7 @@ TEST(15)
EXPECT_EQ (tl::relative_path (xpath2, xpath2), "");
EXPECT_EQ (tl::relative_path (xpath2, xpath), "doesnotexist");
EXPECT_EQ (tl::relative_path (xpath2, tl::combine_path (xpath, "a")), "doesnotexist/a");
EXPECT_EQ (tl::replaced (tl::relative_path (xpath2, tl::combine_path (xpath, "a")), "\\", "/"), "doesnotexist/a");
}
// dir_entries
@ -628,3 +629,43 @@ TEST(16)
EXPECT_EQ (tl::rm_dir (tt), false); // not empty
}
// is_same_file
TEST (17)
{
std::string currdir = tl::current_dir ();
std::string currdir_abs = tl::absolute_file_path (".");
EXPECT_EQ (currdir, currdir_abs);
EXPECT_EQ (tl::is_same_file (currdir, "."), true);
EXPECT_EQ (tl::is_same_file (".", currdir), true);
std::string above = tl::absolute_file_path ("..");
EXPECT_EQ (tl::is_same_file (currdir, above), false);
EXPECT_EQ (tl::is_same_file (above, currdir), false);
std::string tp = tl::absolute_file_path (tmp_file ());
std::string dpath = tl::combine_path (tp, "d");
EXPECT_EQ (tl::mkpath (dpath), true);
std::string xfile = tl::combine_path (dpath, "x");
std::string yfile = tl::combine_path (dpath, "y");
{
tl::OutputStream os (xfile);
os << "hello, world!";
}
{
tl::OutputStream os (yfile);
os << "hello, world II!";
}
EXPECT_EQ (tl::file_exists (xfile), true);
EXPECT_EQ (tl::is_same_file (xfile, tp), false);
EXPECT_EQ (tl::is_same_file (dpath, xfile), false);
EXPECT_EQ (tl::is_parent_path (dpath, xfile), true);
EXPECT_EQ (tl::is_parent_path (xfile, dpath), false);
EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/x"), xfile), true);
EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/y"), xfile), false);
EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/y"), yfile), true);
EXPECT_EQ (tl::is_same_file (xfile, tl::combine_path (dpath, "../d/x")), true);
EXPECT_EQ (tl::is_same_file (xfile, tl::combine_path (dpath, "../d/y")), false);
EXPECT_EQ (tl::is_same_file (yfile, tl::combine_path (dpath, "../d/y")), true);
}