diff --git a/plasmoid/CMakeLists.txt b/plasmoid/CMakeLists.txt index 1e27747..340fba5 100644 --- a/plasmoid/CMakeLists.txt +++ b/plasmoid/CMakeLists.txt @@ -65,7 +65,7 @@ endforeach () plasma_install_package("${PLASMOID_PACKAGE_DIR}" "${META_ID}") # add target to ease testing the plasmoid (see testing.md) -set(PLASMOID_TESTDIR "${CMAKE_CURRENT_BINARY_DIR}/testdir" CACHE STRING "specifies the Plasmoid test directory") +set(PLASMOID_TESTDIR "${CMAKE_BINARY_DIR}" CACHE STRING "specifies the Plasmoid test directory") file(MAKE_DIRECTORY "${PLASMOID_TESTDIR}") add_custom_target(init_plasmoid_testing COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/inittesting.sh" "${PLASMOID_CONFIG_TARGET_FILE_ABSOLUTE_PATH}" diff --git a/plasmoid/scripts/inittesting.sh b/plasmoid/scripts/inittesting.sh index d4f4535..4c58561 100755 --- a/plasmoid/scripts/inittesting.sh +++ b/plasmoid/scripts/inittesting.sh @@ -1,16 +1,17 @@ #!/bin/bash set -e +script_dir=$(dirname "${BASH_SOURCE[0]}") +source "$script_dir/settestenv.sh" # use the package dir within the source-tree so one does not need to run CMake again for updating # build-tree copy all the time -package_dir=$(dirname $0)/../package +package_dir=$script_dir/../package # copy the generated desktop file back into the source-tree package dir so it can actually be used meta_data_file=$1 cp --target-directory="$package_dir" "$meta_data_file" # install or update the package into the working directory -export HOME="$PWD" if ! plasmapkg2 --install "$package_dir"; then plasmapkg2 --upgrade "$package_dir" fi diff --git a/plasmoid/scripts/settestenv.sh b/plasmoid/scripts/settestenv.sh new file mode 100755 index 0000000..5dad8c6 --- /dev/null +++ b/plasmoid/scripts/settestenv.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# use a sub directory within the build directory which is supposed to be $PWD +echo $PWD +export HOME=${TEST_HOME:-$PWD/plasmoid-testing} +echo "HOME directory used for Plasmoid testing: $HOME" +mkdir -p "$HOME" + +# unset XDG_DATA_HOME and XDG_CONFIG_HOME to use Qt's default relying on just HOME (see qtbase/src/corelib/io/qstandardpaths_unix.cpp for defaults) +export XDG_DATA_HOME= +export XDG_CONFIG_HOME= + +# set QT_PLUGIN_PATH if it has not already been set +if ! [[ $QT_PLUGIN_PATH ]]; then + if [[ -f $PWD/syncthingtray/plasmoid/lib/plasma/applets/libsyncthingplasmoid.so ]]; then + export QT_PLUGIN_PATH=$PWD/syncthingtray/plasmoid/lib + elif [[ -f $PWD/plasmoid/lib/plasma/applets/libsyncthingplasmoid.so ]]; then + export QT_PLUGIN_PATH=$PWD/plasmoid/lib + fi + echo "QT_PLUGIN_PATH used for Plasmoid testing: $QT_PLUGIN_PATH" +fi diff --git a/plasmoid/scripts/starttesting.sh b/plasmoid/scripts/starttesting.sh new file mode 100755 index 0000000..c6b9950 --- /dev/null +++ b/plasmoid/scripts/starttesting.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +script_dir=$(dirname "${BASH_SOURCE[0]}") +source "$script_dir/settestenv.sh" +exec "$@" diff --git a/plasmoid/testing.md b/plasmoid/testing.md index e344baf..e6d4a04 100644 --- a/plasmoid/testing.md +++ b/plasmoid/testing.md @@ -4,19 +4,24 @@ The following instructions allow to test the Plasmoid by installing it in a test rather than the regular home to separate testing from production. 1. Build as usual, ensure `NO_PLASMOID` is turned off -2. Add build step to execute custom target `init_plasmoid_testing` which - will install the Plasmoid in a test directory which is "$BUILD_DIR/plasmoid/testdir" +2. Add build step to execute the custom target `init_plasmoid_testing` which + will install the Plasmoid in a test directory which is `$CMAKE_BUILD_DIR/plasmoid-testing` by default -3. Add new config for run in Qt Creator and set `plasmoidviewer` (or `plasmawindowed`) - as executable -4. In execution environment, set - * `QT_PLUGIN_PATH` to `$BUILD_DIR/plasmoid/lib` which should be containing the plugin - for the Plasmoid under `plasma/applets/libsyncthingplasmoid.so` - * `QT_DEBUG_PLUGINS` to 1 for verbose plugin detection - * `HOME` to the test directory from step 2 so plasmoidviewer finds the Plasmoid - in the test directory -5. Set `--applet martchus.syncthingplasmoid` as CLI argument -6. Ignore warning that executable is no debug build, it is sufficiant when +3. Add new config for run in Qt Creator and set `bash` as executable +4. Set `%{sourceDir}/../../syncthingtray/plasmoid/scripts/starttesting.sh plasmoidviewer --applet martchus.syncthingplasmoid` + as CLI argument + * It is also possible to use `plasmawindowed` or `plasmashell`, see sections below. + * This usage of `%{sourceDir}` assumes one used the "Building this straight" instructions + from the main README.md. +5. Keep `%{buildDir}` as working directory. +6. In execution environment there's nothing mandatory to be set because `starttesting.sh` should + already take care of setting the environment. + * The home directory is set in accordance with the directory used in step 2. but can be overridden + by setting `TEST_HOME` + * If not already set, `QT_PLUGIN_PATH` is set to `$CMAKE_CURRENT_BINARY_DIR/plasmoid/lib` which + should contain the plugin for the Plasmoid under `plasma/applets/libsyncthingplasmoid.so` + * `QT_DEBUG_PLUGINS` to 1 for verbose plugin detection +7. Ignore warning that executable is no debug build, it is sufficiant when the plugin is a debug build (see next section for QML debugging) ## Saving/restoring settings