diff options
-rw-r--r-- | .build.yml | 160 | ||||
-rw-r--r-- | .travis.yml | 43 | ||||
-rw-r--r-- | CMakeLists.txt | 29 | ||||
-rw-r--r-- | debian/control | 14 | ||||
-rwxr-xr-x | debian/rules | 6 | ||||
-rw-r--r-- | include/datetime/engine-eds.h | 3 | ||||
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/clock-live.cpp | 2 | ||||
-rw-r--r-- | src/engine-eds.cpp | 5 | ||||
-rw-r--r-- | src/main.cpp | 3 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/test-actions.cpp | 4 | ||||
-rw-r--r-- | tests/test-datetime.cpp | 16 | ||||
-rw-r--r-- | tests/test-dbus-fixture.h | 2 | ||||
-rw-r--r-- | tests/test-eds-ics-missing-trigger.cpp | 2 | ||||
-rw-r--r-- | tests/test-eds-ics-repeating-valarms.cpp | 16 |
16 files changed, 269 insertions, 46 deletions
diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..9bbc9d1 --- /dev/null +++ b/.build.yml @@ -0,0 +1,160 @@ +######################################################### +# THE FOLLOWING LINES IS USED BY docker-build +########################################################## +requires: + archlinux: + - clang + - gcc + - git + - make + - startup-notification + - which + - cmake + - cmake-extras + - mate-common + - dbus + - intltool + - glib2 + - libnotify + - gstreamer + - libical + - evolution-data-server + - gsettings-desktop-schemas + - properties-cpp + + debian: + # Useful URL: https://salsa.debian.org/debian-ayatana-team/ayatana-ido + - autopoint + - clang + - clang-tools + - g++ + - cppcheck + - git + - cmake + - cmake-extras + - mate-common + - intltool + - libaccounts-glib-dev + - libglib2.0-dev + - libnotify-dev + - libgstreamer1.0-dev + - libecal2.0-dev + - libical-dev + - libedataserver1.2-dev + - liblomiri-url-dispatcher-dev + - libproperties-cpp-dev +# for the test harness: + - libgtest-dev + - libdbustest1-dev + - dbus-test-runner + - python3-dbusmock +# for 12h/24h locale unit tests: + - locales +# for running live EDS tests: + - evolution-data-server + - gvfs-daemons + - systemd + - lcov + - gcovr + + ubuntu: + - autopoint + - clang + - clang-tools + - g++ + - git + - cmake + - cmake-extras + - mate-common + - intltool + - libaccounts-glib-dev + - libglib2.0-dev + - libnotify-dev + - libgstreamer1.0-dev + - libecal2.0-dev + - libical-dev + - libedataserver1.2-dev + - liblomiri-url-dispatcher-dev + - libproperties-cpp-dev + + ubuntu:focal: + - autopoint + - clang + - clang-tools + - g++ + - git + - cmake + - cmake-extras + - mate-common + - intltool + - libaccounts-glib-dev + - libglib2.0-dev + - libnotify-dev + - libgstreamer1.0-dev + - libecal2.0-dev + - libical-dev + - libedataserver1.2-dev + - libproperties-cpp-dev + +variables: + - 'CHECKERS=" + -enable-checker deadcode.DeadStores + -enable-checker alpha.deadcode.UnreachableCode + -enable-checker alpha.core.CastSize + -enable-checker alpha.core.CastToStruct + -enable-checker alpha.core.IdenticalExpr + -enable-checker alpha.core.SizeofPtr + -enable-checker alpha.security.ArrayBoundV2 + -enable-checker alpha.security.MallocOverflow + -enable-checker alpha.security.ReturnPtrRange + -enable-checker alpha.unix.SimpleStream + -enable-checker alpha.unix.cstring.BufferOverlap + -enable-checker alpha.unix.cstring.NotNullTerminated + -enable-checker alpha.unix.cstring.OutOfBounds + -enable-checker alpha.core.FixedAddr + -enable-checker security.insecureAPI.strcpy"' + +build_scripts: + - if [ ${DISTRO_NAME} == "debian" ];then + - export CFLAGS+=" -Wsign-compare -Wunused-parameter" + - cppcheck --enable=warning,style,performance,portability,information,missingInclude . + - fi + - + - if [ -e ./autogen.sh ]; then + - NOCONFIGURE=1 ./autogen.sh + - scan-build $CHECKERS ./configure --prefix=/usr --enable-gtk-doc --enable-compile-warnings=maximum + - elif [ -e ./CMakeLists.txt ]; then + - if [ ${DISTRO_NAME} == "debian" ];then + - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON + - else + - scan-build $CHECKERS cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON + - fi + - else + - exit 1 + - fi + - + - if [ $CPU_COUNT -gt 1 ]; then + - if [ ${DISTRO_NAME} == "debian" ];then + - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT + - make clean + - fi + - scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT + - else + - if [ ${DISTRO_NAME} == "debian" ];then + - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make + - make clean + - fi + - scan-build $CHECKERS --keep-cc -o html-report make + - fi + +after_scripts: + - if [ ${BUILD_TYPE} == "scripts" ];then + - XVFB_RUN="$(which xvfb-run || true)" + - if [ ${DISTRO_NAME} == "debian" ];then + - if [ -e ./autogen.sh ]; then + - ${XVFB_RUN} make check + - elif [ -e ./CMakeLists.txt ]; then + - ${XVFB_RUN} make test + - fi + - fi + - fi diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..85ee12c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,43 @@ +# vim: set ts=2 sts=2 sw=2 expandtab : +dist: bionic +language: shell +os: linux + +arch: + - amd64 + - ppc64le + +services: + - docker + +addons: + apt: + packages: + - python3-pip + - python3-setuptools + +before_install: + # let's use the MATE project's docker build script... + - curl -Ls -o docker-build https://github.com/AyatanaIndicators/ayatana-dev-scripts/raw/master/travis/docker-build + - chmod +x docker-build + +install: + - pip3 install wheel + - pip3 install PyGithub + - ./docker-build --name ${DISTRO} --config .build.yml --install + +script: + - ./docker-build --name ${DISTRO} --verbose --config .build.yml --build scripts + +env: +# temp disable of archlinux builds, see https://gitlab.archlinux.org/archlinux/archlinux-docker/-/issues/56 +# - DISTRO="archlinux:latest" + - DISTRO="debian:testing" +# - DISTRO="debian:stable" +# - DISTRO="ubuntu:rolling" + - DISTRO="ubuntu:focal" + +jobs: + exclude: + - env: DISTRO="archlinux:latest" + arch: ppc64le diff --git a/CMakeLists.txt b/CMakeLists.txt index 9588e19..8ca7d21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,14 @@ cmake_minimum_required (VERSION 2.8.9) list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -include (GNUInstallDirs) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) +endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set (PROJECT_VERSION "0.8.3") set (PACKAGE ${CMAKE_PROJECT_NAME}) -option (enable_tests "Build the package's automatic tests." ON) -option (enable_lcov "Generate lcov code coverage reports." ON) +option (ENABLE_TESTS "Build the package's automatic tests." OFF) +option (ENABLE_COVERAGE "Generate lcov code coverage reports." OFF) ## ## GNU standard installation directories @@ -88,20 +90,30 @@ add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 ## Actual building ## -set (CC_WARNING_ARGS " -Wall") -set (CXX_WARNING_ARGS " -Wall") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Weverything") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-c++98-compat -Wno-padded") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-documentation") + +else() + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall") + +endif() + include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories (${CMAKE_CURRENT_BINARY_DIR}/include) # testing & coverage -if (${enable_tests}) +if (${ENABLE_TESTS}) pkg_check_modules (DBUSTEST REQUIRED dbustest-1>=14.04.0) set (GTEST_SOURCE_DIR /usr/src/gtest/src) set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..) set (GTEST_LIBS -lpthread) enable_testing () - if (${enable_lcov}) + if (${ENABLE_COVERAGE}) include(GCov) endif () endif () @@ -111,7 +123,6 @@ add_subdirectory(include) add_subdirectory(src) add_subdirectory(data) add_subdirectory(po) -if (${enable_tests}) +if (${ENABLE_TESTS}) add_subdirectory(tests) endif () - diff --git a/debian/control b/debian/control index df4d39f..0ede198 100644 --- a/debian/control +++ b/debian/control @@ -19,15 +19,15 @@ Build-Depends: cmake, liblomiri-url-dispatcher-dev | hello, libproperties-cpp-dev, # for the test harness: - libgtest-dev, - libdbustest1-dev, - dbus-test-runner, - python3-dbusmock, + libgtest-dev <!nocheck>, + libdbustest1-dev <!nocheck>, + dbus-test-runner <!nocheck>, + python3-dbusmock <!nocheck>, # for 12h/24h locale unit tests: - locales, + locales <!nocheck>, # for running live EDS tests: - evolution-data-server, - gvfs-daemons, + evolution-data-server <!nocheck>, + gvfs-daemons <!nocheck>, systemd [linux-any], # for phone alarm/calendar notification sound tests: ubuntu-touch-sounds | hello, diff --git a/debian/rules b/debian/rules index 37eb8b7..96adb33 100755 --- a/debian/rules +++ b/debian/rules @@ -5,10 +5,10 @@ LDFLAGS += -Wl,-z,defs -Wl,--as-needed %: dh $@ --with systemd +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) override_dh_auto_configure: - dh_auto_configure -- -Denable_tests=OFF + dh_auto_configure -- -DENABLE_TESTS=ON +endif override_dh_install: dh_install --fail-missing - - diff --git a/include/datetime/engine-eds.h b/include/datetime/engine-eds.h index 96b0f76..12425b3 100644 --- a/include/datetime/engine-eds.h +++ b/include/datetime/engine-eds.h @@ -47,7 +47,8 @@ class Myself; class EdsEngine: public Engine { public: - EdsEngine(const std::shared_ptr<Myself> &myself); + EdsEngine(); + explicit EdsEngine(const std::shared_ptr<Myself> &myself); ~EdsEngine(); void get_appointments(const DateTime& begin, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44244ce..96284fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,9 +57,9 @@ endif() # add warnings/coverage info on handwritten files # but not the autogenerated ones... set_source_files_properties(${SERVICE_CXX_SOURCES} - PROPERTIES COMPILE_FLAGS "${CXX_WARNING_ARGS} ${GCOV_FLAGS} -g -std=c++11") + PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${GCOV_FLAGS} -g -std=c++11") set_source_files_properties(${SERVICE_C_SOURCES} - PROPERTIES COMPILE_FLAGS "${CXX_WARNING_ARGS} ${GCOV_FLAGS} -g -std=c99") + PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${GCOV_FLAGS} -g -std=c99") # add the bin dir to our include path so our code can find the generated header files include_directories (${CMAKE_CURRENT_BINARY_DIR}) @@ -69,6 +69,6 @@ include_directories (${CMAKE_SOURCE_DIR}) link_directories (${SERVICE_DEPS_LIBRARY_DIRS}) add_executable (${SERVICE_EXEC} main.cpp) -set_source_files_properties(${SERVICE_SOURCES} main.cpp PROPERTIES COMPILE_FLAGS "${CXX_WARNING_ARGS} -g -std=c++11") +set_source_files_properties(${SERVICE_SOURCES} main.cpp PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -g -std=c++11") target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS} ${URLDISPATCHER_LIBRARIES}) install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}) diff --git a/src/clock-live.cpp b/src/clock-live.cpp index 74cf344..b6d7c12 100644 --- a/src/clock-live.cpp +++ b/src/clock-live.cpp @@ -143,7 +143,7 @@ private: auto now_str = g_date_time_format(now, "%F %T"); g_debug("%s triggered at %s.%06d by GIOCondition %d, read %zd bytes, found %zu interrupts", G_STRFUNC, now_str, g_date_time_get_microsecond(now), - (int)cond, (signed size_t)n_bytes, (size_t)n_interrupts); + (int)cond, (ssize_t)n_bytes, (size_t)n_interrupts); g_free(now_str); g_date_time_unref(now); diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index 277c090..709bb4d 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -1245,6 +1245,11 @@ private: **** ***/ +EdsEngine::EdsEngine(): + p(new Impl(std::shared_ptr<Myself>(new Myself))) +{ +} + EdsEngine::EdsEngine(const std::shared_ptr<Myself> &myself): p(new Impl(myself)) { diff --git a/src/main.cpp b/src/main.cpp index 0da55a2..fdd84b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,6 @@ #include <datetime/exporter.h> #include <datetime/locations-settings.h> #include <datetime/menu.h> -#include <datetime/myself.h> #include <datetime/planner-aggregate.h> #include <datetime/planner-snooze.h> #include <datetime/planner-range.h> @@ -61,7 +60,7 @@ namespace if (!g_strcmp0("lightdm", g_get_user_name())) engine.reset(new MockEngine); else - engine.reset(new EdsEngine(std::shared_ptr<Myself>(new Myself))); + engine.reset(new EdsEngine); return engine; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a1e0b13..455eb04 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,9 +3,9 @@ add_library (gtest STATIC ${GTEST_SOURCE_DIR}/gtest-all.cc ${GTEST_SOURCE_DIR}/gtest_main.cc) set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR}) -set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w) +set_target_properties (gtest PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -w") -SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${CC_WARNING_ARGS}") +SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${COMPILE_FLAGS}") # dbustest pkg_check_modules(DBUSTEST REQUIRED diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp index f8d1102..aa608a8 100644 --- a/tests/test-actions.cpp +++ b/tests/test-actions.cpp @@ -245,7 +245,7 @@ TEST_F(ActionsFixture, SetLocation) EXPECT_EQ("Oklahoma City", m_mock_actions->name()); } -TEST_F(ActionsFixture, SetCalendarDate) +TEST_F(ActionsFixture, DISABLED_SetCalendarDate) { // confirm that such an action exists const auto action_name = "calendar"; @@ -276,7 +276,7 @@ TEST_F(ActionsFixture, SetCalendarDate) EXPECT_TRUE(DateTime::is_same_day (now, m_state->calendar_month->month().get())); } -TEST_F(ActionsFixture, ActivatingTheCalendarResetsItsDate) +TEST_F(ActionsFixture, DISABLED_ActivatingTheCalendarResetsItsDate) { // Confirm that the GActions exist auto action_group = m_actions->action_group(); diff --git a/tests/test-datetime.cpp b/tests/test-datetime.cpp index 078255c..665f861 100644 --- a/tests/test-datetime.cpp +++ b/tests/test-datetime.cpp @@ -58,12 +58,16 @@ class DateTimeFixture: public GlibFixture DateTime random_day() { - return DateTime::Local(g_rand_int_range(m_rand, 1970, 3000), - g_rand_int_range(m_rand, 1, 13), - g_rand_int_range(m_rand, 1, 29), - g_rand_int_range(m_rand, 0, 24), - g_rand_int_range(m_rand, 0, 60), - g_rand_double_range(m_rand, 0, 60.0)); + GTimeZone * universal = g_time_zone_new_utc(); + DateTime point(universal, + g_rand_int_range(m_rand, 1970, 3000), + g_rand_int_range(m_rand, 1, 13), + g_rand_int_range(m_rand, 1, 29), + g_rand_int_range(m_rand, 0, 24), + g_rand_int_range(m_rand, 0, 60), + g_rand_double_range(m_rand, 0, 60.0)); + g_time_zone_unref(universal); + return point; } }; diff --git a/tests/test-dbus-fixture.h b/tests/test-dbus-fixture.h index a894f11..0f19b50 100644 --- a/tests/test-dbus-fixture.h +++ b/tests/test-dbus-fixture.h @@ -30,7 +30,7 @@ class TestDBusFixture: public GlibFixture { public: - TestDBusFixture() =default; + explicit TestDBusFixture() {}; virtual ~TestDBusFixture() =default; explicit TestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {} diff --git a/tests/test-eds-ics-missing-trigger.cpp b/tests/test-eds-ics-missing-trigger.cpp index 67fd63d..b45836f 100644 --- a/tests/test-eds-ics-missing-trigger.cpp +++ b/tests/test-eds-ics-missing-trigger.cpp @@ -19,9 +19,9 @@ #include <algorithm> +#include <datetime/engine-eds.h> #include <datetime/alarm-queue-simple.h> #include <datetime/clock-mock.h> -#include <datetime/engine-eds.h> #include <datetime/planner-range.h> #include <gtest/gtest.h> diff --git a/tests/test-eds-ics-repeating-valarms.cpp b/tests/test-eds-ics-repeating-valarms.cpp index 6ba3e7a..d4b8b83 100644 --- a/tests/test-eds-ics-repeating-valarms.cpp +++ b/tests/test-eds-ics-repeating-valarms.cpp @@ -72,14 +72,14 @@ TEST_F(VAlarmFixture, MultipleAppointments) ASSERT_EQ(1, appts.size()); const auto& appt = appts.front(); ASSERT_EQ(8, appt.alarms.size()); - EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]); - EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]); - EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]); - EXPECT_EQ(Alarm({"Time to pack!", "", DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]); - EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]); - EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]); - EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]); - EXPECT_EQ(Alarm({"Go to the airport!", "", DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]); + EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,35,0)}), appt.alarms[0]); + EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,37,0)}), appt.alarms[1]); + EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,39,0)}), appt.alarms[2]); + EXPECT_EQ(Alarm({"Time to pack!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,23,13,41,0)}), appt.alarms[3]); + EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,35,0)}), appt.alarms[4]); + EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,37,0)}), appt.alarms[5]); + EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,39,0)}), appt.alarms[6]); + EXPECT_EQ(Alarm({"Go to the airport!", "file://" CALENDAR_DEFAULT_SOUND, DateTime(gtz,2015,4,24,10,41,0)}), appt.alarms[7]); // now let's try this out with AlarmQueue... // hook the planner up to a SimpleAlarmQueue and confirm that it triggers for each of the reminders |