diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4d97a840..3f8a383f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -82,7 +82,6 @@ externalproject_add(inttest_bin "-DGTEST_ROOT:path=${GTEST_ROOT}" "-DGMOCK_ROOT:path=${GMOCK_ROOT}" "-DZNC_BIN_DIR:path=${CMAKE_INSTALL_FULL_BINDIR}" - "-DZNC_SRC_DIR:path=${PROJECT_SOURCE_DIR}" "-DQt5_HINTS:path=${brew_qt5}") add_custom_target(inttest COMMAND "${CMAKE_CURRENT_BINARY_DIR}/integration/inttest") diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 6adfa576..2980936b 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -42,5 +42,4 @@ target_include_directories(inttest PUBLIC "${GTEST_ROOT}" "${GTEST_ROOT}/include" "${GMOCK_ROOT}" "${GMOCK_ROOT}/include") target_compile_definitions(inttest PRIVATE - "ZNC_BIN_DIR=\"${ZNC_BIN_DIR}\"" - "ZNC_SRC_DIR=\"${ZNC_SRC_DIR}\"") + "ZNC_BIN_DIR=\"${ZNC_BIN_DIR}\"") diff --git a/test/integration/main.cpp b/test/integration/main.cpp index e799f53e..490f014d 100644 --- a/test/integration/main.cpp +++ b/test/integration/main.cpp @@ -45,10 +45,6 @@ #define ZNC_BIN_DIR "" #endif -#ifndef ZNC_SRC_DIR -#define ZNC_SRC_DIR "" -#endif - using testing::AnyOf; using testing::Eq; using testing::HasSubstr; @@ -1848,25 +1844,42 @@ TEST_F(ZNCTest, BuildMod) { Z; auto client = LoginClient(); Z; + QTemporaryDir srcd; + QDir srcdir(srcd.path()); + QFile file(srcdir.filePath("testmod.cpp")); + ASSERT_TRUE(file.open(QIODevice::WriteOnly | QIODevice::Text)); + QTextStream out(&file); + out << R"( + #include + class TestModule : public CModule { + public: + MODCONSTRUCTOR(TestModule) {} + void OnModCommand(const CString& sLine) override { + PutModule("Lorem ipsum"); + } + }; + MODULEDEFS(TestModule, "Test") + )"; + file.close(); QDir dir(m_dir.path()); EXPECT_TRUE(dir.mkdir("modules")); EXPECT_TRUE(dir.cd("modules")); { Process p(ZNC_BIN_DIR "/znc-buildmod", - QStringList() << ZNC_SRC_DIR "/test/file-not-found.cpp", + QStringList() << srcdir.filePath("file-not-found.cpp"), [&](QProcess* proc) { - proc->setWorkingDirectory(dir.absolutePath()); - proc->setProcessChannelMode(QProcess::ForwardedChannels); - }); + proc->setWorkingDirectory(dir.absolutePath()); + proc->setProcessChannelMode(QProcess::ForwardedChannels); + }); p.ShouldFinishItself(1); } { Process p(ZNC_BIN_DIR "/znc-buildmod", - QStringList() << ZNC_SRC_DIR "/test/testmod.cpp", + QStringList() << srcdir.filePath("testmod.cpp"), [&](QProcess* proc) { - proc->setWorkingDirectory(dir.absolutePath()); - proc->setProcessChannelMode(QProcess::ForwardedChannels); - }); + proc->setWorkingDirectory(dir.absolutePath()); + proc->setProcessChannelMode(QProcess::ForwardedChannels); + }); p.ShouldFinishItself(); } client.Write("znc loadmod testmod"); diff --git a/test/testmod.cpp b/test/testmod.cpp deleted file mode 100644 index 3cb4f1cb..00000000 --- a/test/testmod.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2004-2016 ZNC, see the NOTICE file for details. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -class TestModule : public CModule { - public: - MODCONSTRUCTOR(TestModule) {} - void OnModCommand(const CString& sLine) override { - PutModule("Lorem ipsum"); - } -}; - -MODULEDEFS(TestModule, "Test")