diff --git a/kodi_game_scripting/template_processor.py b/kodi_game_scripting/template_processor.py
index 4d75f1a9..abf2f23a 100644
--- a/kodi_game_scripting/template_processor.py
+++ b/kodi_game_scripting/template_processor.py
@@ -31,6 +31,19 @@
'templates')
+def get_list(value):
+ """ Filter: Returns a list (existing list or new single elemented list) """
+ return value if isinstance(value, list) else [value]
+
+
+def regex_replace(string, find, replace, *, multiline=False):
+ """ Filter: Replace regex in string """
+ flags = 0
+ if multiline:
+ flags += re.MULTILINE
+ return re.sub(find, replace, string, flags=flags)
+
+
class TemplateProcessor:
""" Process Jinja2 templates """
@@ -51,17 +64,7 @@ def __getattr__(self, key):
trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True,
undefined=_TreeUndefined)
- def regex_replace(string, find, replace, multiline=False):
- """ Replaces regex in string """
- flags = 0
- if multiline:
- flags += re.MULTILINE
- return re.sub(find, replace, string, flags=flags)
template_env.filters["regex_replace"] = regex_replace
-
- def get_list(value):
- """ Returns a list (existing list or new single elemented list) """
- return value if isinstance(value, list) else [value]
template_env.filters["get_list"] = get_list
# Loop over all templates
diff --git a/templates/addon/{{ game.addon }}/addon.xml.in.j2 b/templates/addon/{{ game.addon }}/addon.xml.in.j2
index 63292de2..a13c9a31 100644
--- a/templates/addon/{{ game.addon }}/addon.xml.in.j2
+++ b/templates/addon/{{ game.addon }}/addon.xml.in.j2
@@ -31,14 +31,14 @@
{% endif %}
{% set description = xml.addon.extension[1].description.content | default('') %}
{% if ("Supported files: " in xml.addon.extension[1].description.content) %}
- {% set description = xml.addon.extension[1].description.content | regex_replace('Supported files: (?:\.\w+)(?:,\s*\.\w+)*', extensions | default('')) %}
+ {% set description = xml.addon.extension[1].description.content | regex_replace('Supported files: (?:\\.\\w+)(?:,\\s*\\.\\w+)*', extensions | default('')) %}
{% elif extensions %}
{% set description = xml.addon.extension[1].description.content | default('') + '\n\n' + extensions %}
{% endif %}
{% if ("License: " in xml.addon.extension[1].description.content) %}
{% set description = description | regex_replace('License: .*', '') %}
{% endif %}
- {% set description = description | regex_replace('^(\s*\\n){2,}', '\n', multiline=True) | trim %}
+ {% set description = description | regex_replace('^(\\s*\\n){2,}', '\n', multiline=True) | trim %}
{{ description | e }}
{% if xml.addon.extension[1].disclaimer %}
{{ xml.addon.extension[1].disclaimer.content | e }}
diff --git a/templates/addon/{{ game.addon }}/resources/settings.xml.j2 b/templates/addon/{{ game.addon }}/resources/settings.xml.j2
index 0af6cd72..9226de4d 100644
--- a/templates/addon/{{ game.addon }}/resources/settings.xml.j2
+++ b/templates/addon/{{ game.addon }}/resources/settings.xml.j2
@@ -3,7 +3,7 @@
{% for setting in settings %}
-
+
{% endfor %}
diff --git a/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE.md b/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 00000000..e685bf48
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,67 @@
+---
+name: Problem report
+about: Create an extensive report to help us document a problem
+
+---
+
+
+## Bug report
+### Describe the bug
+Here is a clear and concise description of what the problem is:
+
+
+
+
+
+
+## RetroArch Behavior
+Here is a clear and concise description of what happens in RetroArch with the same core/game:
+
+
+
+
+
+### To Reproduce
+Steps to reproduce the behavior:
+
+
+
+1.
+2.
+3.
+
+
+### Debuglog
+
+
+The debuglog can be found here:
+
+
+
+### Screenshots
+Here are some links or screenshots to help explain the problem:
+
+
+
+
+### Your Environment
+Used Operating system:
+
+
+ - [ ] Android
+ - [ ] iOS
+ - [ ] Linux
+ - [ ] OSX
+ - [ ] Raspberri-Pi
+ - [ ] Windows
+ - [ ] Windows UWP
+
+Operating system version/name:
+
+Kodi version:
+
+
+
+
+*note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
+Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.*
\ No newline at end of file
diff --git a/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE/bug_report.md b/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..e685bf48
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,67 @@
+---
+name: Problem report
+about: Create an extensive report to help us document a problem
+
+---
+
+
+## Bug report
+### Describe the bug
+Here is a clear and concise description of what the problem is:
+
+
+
+
+
+
+## RetroArch Behavior
+Here is a clear and concise description of what happens in RetroArch with the same core/game:
+
+
+
+
+
+### To Reproduce
+Steps to reproduce the behavior:
+
+
+
+1.
+2.
+3.
+
+
+### Debuglog
+
+
+The debuglog can be found here:
+
+
+
+### Screenshots
+Here are some links or screenshots to help explain the problem:
+
+
+
+
+### Your Environment
+Used Operating system:
+
+
+ - [ ] Android
+ - [ ] iOS
+ - [ ] Linux
+ - [ ] OSX
+ - [ ] Raspberri-Pi
+ - [ ] Windows
+ - [ ] Windows UWP
+
+Operating system version/name:
+
+Kodi version:
+
+
+
+
+*note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
+Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.*
\ No newline at end of file
diff --git a/tests/integration/test_data/test_template_processor/addon/.gitignore b/tests/integration/test_data/test_template_processor/addon/.gitignore
new file mode 100644
index 00000000..51906626
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/.gitignore
@@ -0,0 +1,30 @@
+# build artifacts
+build/
+obj-x86_64-linux-gnu/
+game.*/addon.xml
+
+# commonly used editors
+# vim
+*.swp
+
+# Eclipse
+*.project
+*.cproject
+.classpath
+.settings/
+
+# Sublime
+*.sublime-*
+
+# KDevelop 4
+*.kdev4
+
+# gedit
+*~
+
+# CLion
+.idea
+
+# OSX ignorables
+.DS_Store
+._*
diff --git a/tests/integration/test_data/test_template_processor/addon/.travis.yml b/tests/integration/test_data/test_template_processor/addon/.travis.yml
new file mode 100644
index 00000000..603f2d27
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/.travis.yml
@@ -0,0 +1,41 @@
+language: cpp
+
+#
+# Define the build matrix
+#
+# Travis defaults to building on Ubuntu Precise when building on
+# Linux. We need Trusty in order to get up to date versions of
+# cmake and g++.
+#
+env:
+ global:
+ - app_id=game.libretro.mygame
+
+matrix:
+ include:
+ - os: linux
+ dist: xenial
+ sudo: required
+ compiler: gcc
+ - os: linux
+ dist: xenial
+ sudo: required
+ compiler: clang
+ - os: osx
+ osx_image: xcode9
+ - os: osx
+ osx_image: xcode9.3
+
+#
+# The addon source is automatically checked out in $TRAVIS_BUILD_DIR,
+# we'll put the Kodi source on the same level
+#
+before_script:
+ - cd $TRAVIS_BUILD_DIR/..
+ - git clone --depth=1 https://github.com/xbmc/xbmc.git
+ - cd ${app_id} && mkdir build && cd build
+ - mkdir -p definition/${app_id}
+ - echo ${app_id} $TRAVIS_BUILD_DIR $TRAVIS_COMMIT > definition/${app_id}/${app_id}.txt
+ - cmake -DADDONS_TO_BUILD=${app_id} -DADDON_SRC_PREFIX=$TRAVIS_BUILD_DIR/.. -DADDONS_DEFINITION_DIR=$TRAVIS_BUILD_DIR/build/definition -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/../xbmc/addons -DPACKAGE_ZIP=1 $TRAVIS_BUILD_DIR/../xbmc/cmake/addons
+
+script: make -j$(getconf _NPROCESSORS_ONLN)
diff --git a/tests/integration/test_data/test_template_processor/addon/CMakeLists.txt b/tests/integration/test_data/test_template_processor/addon/CMakeLists.txt
new file mode 100644
index 00000000..dcf15dcc
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+project(game.libretro.mygame)
+
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+
+find_package(Kodi REQUIRED)
+find_package(libretro-mygame REQUIRED)
+
+set(MYGAME_CUSTOM_BINARY ${MYGAME_LIB}
+ ${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+build_addon(${PROJECT_NAME} MYGAME "")
+
+include(CPack)
diff --git a/tests/integration/test_data/test_template_processor/addon/Jenkinsfile b/tests/integration/test_data/test_template_processor/addon/Jenkinsfile
new file mode 100644
index 00000000..cfd0746e
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/Jenkinsfile
@@ -0,0 +1 @@
+buildPlugin(deploy: ['android-armv7', 'android-aarch64', 'osx-x86_64', 'windows-i686', 'windows-x86_64'])
diff --git a/tests/integration/test_data/test_template_processor/addon/README.md b/tests/integration/test_data/test_template_processor/addon/README.md
new file mode 100644
index 00000000..842081f5
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/README.md
@@ -0,0 +1,6 @@
+# game.libretro.mygame addon for Kodi
+
+This is a [Kodi](http://kodi.tv) game addon for mygame.
+
+[](https://travis-ci.org/kodi-game/game.libretro.mygame)
+[](https://ci.appveyor.com/project/kodi-game/game-libretro-mygame)
diff --git a/tests/integration/test_data/test_template_processor/addon/appveyor.yml b/tests/integration/test_data/test_template_processor/addon/appveyor.yml
new file mode 100644
index 00000000..282eb412
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/appveyor.yml
@@ -0,0 +1,29 @@
+version: BuildNr.{build}
+
+image: Visual Studio 2015
+
+shallow_clone: true
+
+clone_folder: c:\projects\game.libretro.mygame
+
+environment:
+ app_id: game.libretro.mygame
+
+ matrix:
+ - GENERATOR: "Visual Studio 14"
+ CONFIGURATION: Release
+ - GENERATOR: "Visual Studio 14 Win64"
+ CONFIGURATION: Release
+
+build_script:
+ - cd ..
+ - git clone --depth=1 https://github.com/xbmc/xbmc.git
+ - mklink /j xbmc\project\BuildDependencies\msys64 C:\msys64
+ - cd %app_id%
+ - mkdir build
+ - cd build
+ - mkdir -p definition\%app_id%
+ - echo %app_id% %APPVEYOR_BUILD_FOLDER% %APPVEYOR_REPO_COMMIT% > definition\%app_id%\%app_id%.txt
+ - SET PATH=C:\Program Files (x86)\CMake\bin;C:\msys64\bin;C:\msys64\usr\bin;%PATH%
+ - cmake -T host=x64 -G "%GENERATOR%" -DADDONS_TO_BUILD=%app_id% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DADDONS_DEFINITION_DIR=%APPVEYOR_BUILD_FOLDER%/build/definition -DADDON_SRC_PREFIX=../.. -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
+ - cmake --build . --config %CONFIGURATION% --target %app_id%
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/CMakeLists.txt b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/CMakeLists.txt
new file mode 100644
index 00000000..2d2b0dfd
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/CMakeLists.txt
@@ -0,0 +1,63 @@
+cmake_minimum_required(VERSION 3.1)
+project(mygame)
+
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+
+include(ExternalProject)
+
+string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
+
+set(LIBRETRO_BINARY_DIR )
+set(LIBRETRO_SONAME ${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(LIBRETRO_JNISONAME ${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+ set(LIBRETRO_DEBUG DEBUG=1)
+endif()
+
+if(CORE_SYSTEM_NAME STREQUAL windows)
+ find_package(MinGW REQUIRED)
+ set(BUILD_COMMAND ${MINGW_MAKE} -j$ENV{NUMBER_OF_PROCESSORS} -C -f platform=win ${LIBRETRO_DEBUG} GIT_VERSION=)
+elseif(CORE_SYSTEM_NAME STREQUAL linux)
+ set(BUILD_COMMAND $(MAKE) -C -f platform=unix ${LIBRETRO_DEBUG} GIT_VERSION=)
+elseif(CORE_SYSTEM_NAME STREQUAL osx)
+ set(BUILD_COMMAND $(MAKE) -C -f platform=osx ${LIBRETRO_DEBUG} GIT_VERSION=)
+elseif(CORE_SYSTEM_NAME STREQUAL ios)
+ set(LIBRETRO_SONAME _ios${CMAKE_SHARED_LIBRARY_SUFFIX})
+ set(BUILD_COMMAND IOSSDK=${CMAKE_OSX_SYSROOT} $(MAKE) -C -f platform=ios ${LIBRETRO_DEBUG} GIT_VERSION=)
+elseif(CORE_SYSTEM_NAME STREQUAL android)
+ if(NOT NDKROOT)
+ message(FATAL_ERROR "${PROJECT_NAME} needs NDKROOT for Android. Missing Toolchain file?")
+ endif()
+ if(CPU STREQUAL armeabi-v7a)
+ set(PLATFORM android-armv7)
+ elseif(CPU STREQUAL i686)
+ set(PLATFORM x86)
+ else()
+ message(FATAL_ERROR "${PROJECT_NAME} needs Android ${CPU} build command in CMakeLists.txt!")
+ endif()
+ set(LIBRETRO_SONAME _android${CMAKE_SHARED_LIBRARY_SUFFIX})
+ get_filename_component(TOOLCHAIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
+ set(BUILD_COMMAND PATH=${TOOLCHAIN_DIR}:$ENV{PATH} $(MAKE) -C -f platform=${PLATFORM} ${LIBRETRO_DEBUG} GIT_VERSION=)
+elseif(CORE_SYSTEM_NAME STREQUAL rbpi)
+ message(FATAL_ERROR "${PROJECT_NAME} needs RPi build command in CMakeLists.txt!")
+elseif(CORE_SYSTEM_NAME STREQUAL freebsd)
+ set(BUILD_COMMAND $(MAKE) -C -f platform=unix ${LIBRETRO_DEBUG} GIT_VERSION=)
+else()
+ message(FATAL_ERROR "${PROJECT_NAME} - Unknown system: ${CORE_SYSTEM_NAME}")
+endif()
+
+externalproject_add(${PROJECT_NAME}
+ SOURCE_DIR ${PROJECT_SOURCE_DIR}
+ PREFIX ${PROJECT_NAME}
+ CONFIGURE_COMMAND ""
+ INSTALL_COMMAND ""
+ BUILD_COMMAND ${BUILD_COMMAND}
+ BUILD_IN_SOURCE 1)
+
+# install the generated shared library
+install(FILES ${PROJECT_SOURCE_DIR}/${LIBRETRO_BINARY_DIR}/${LIBRETRO_SONAME}
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+
+# write the config.cmake script
+file(WRITE ${CMAKE_INSTALL_PREFIX}/libretro-${PROJECT_NAME}-config.cmake "set(${PROJECT_NAME_UC}_LIB ${CMAKE_INSTALL_PREFIX}/lib/${LIBRETRO_SONAME})")
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/mygame.txt b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/mygame.txt
new file mode 100644
index 00000000..f1abfb7c
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/mygame.txt
@@ -0,0 +1 @@
+mygame https://github.com/libretro/mygame master
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/windows-deps.txt b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/windows-deps.txt
new file mode 100644
index 00000000..90aa6aee
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/common/mygame/windows-deps.txt
@@ -0,0 +1 @@
+mingw
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/01-make.bat.in.patch b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/01-make.bat.in.patch
new file mode 100644
index 00000000..538b8240
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/01-make.bat.in.patch
@@ -0,0 +1,8 @@
+--- /dev/null
++++ b/make.bat.in
+@@ -0,0 +1,5 @@
++@ECHO OFF
++SETLOCAL
++
++SET PATH=@CMAKE_CURRENT_SOURCE_DIR@\@MINGW_PATH@\bin;@CMAKE_CURRENT_SOURCE_DIR@\usr\bin;%PATH%
++make.exe %*
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/02-MinGWConfig.cmake.in.patch b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/02-MinGWConfig.cmake.in.patch
new file mode 100644
index 00000000..b1776260
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/02-MinGWConfig.cmake.in.patch
@@ -0,0 +1,4 @@
+--- /dev/null
++++ b/MinGWConfig.cmake.in
+@@ -0,0 +1,1 @@
++set(MINGW_MAKE @CMAKE_CURRENT_SOURCE_DIR@/@MINGW_PATH@/bin/make.bat)
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/CMakeLists.txt b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/CMakeLists.txt
new file mode 100644
index 00000000..c70a8997
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/CMakeLists.txt
@@ -0,0 +1,36 @@
+cmake_minimum_required(VERSION 3.4)
+
+project(mingw)
+
+foreach(repo msys mingw32 mingw64)
+ if(${repo} STREQUAL msys)
+ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/etc/pacman.d/mirrorlist.${repo} "Server = http://mirrors.kodi.tv/build-deps/win32/msys2/repos/${repo}2/$arch\n")
+ else()
+ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/etc/pacman.d/mirrorlist.${repo} "Server = http://mirrors.kodi.tv/build-deps/win32/msys2/repos/${repo}\n")
+ endif()
+endforeach()
+
+include(CheckSymbolExists)
+check_symbol_exists(_X86_ "Windows.h" _X86_)
+check_symbol_exists(_AMD64_ "Windows.h" _AMD64_)
+
+if(_X86_)
+ set(HOST mingw-w64-i686)
+ set(MINGW_PATH "mingw32")
+elseif(_AMD64_)
+ set(HOST mingw-w64-x86_64)
+ set(MINGW_PATH "mingw64")
+else()
+ message(FATAL_ERROR "Unsupported architecture")
+endif()
+
+execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/usr/bin/bash.exe --login -c "pacman-key --init" ERROR_QUIET)
+execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/usr/bin/bash.exe --login -c "pacman --noconfirm -S make ${HOST}-gcc")
+
+file(GLOB_RECURSE shared_libs ${CMAKE_CURRENT_SOURCE_DIR}/${MINGW_PATH}/*.dll.a)
+file(REMOVE ${shared_libs})
+
+configure_file(MinGWConfig.cmake.in MinGWConfig.cmake @ONLY)
+configure_file(make.bat.in ${CMAKE_CURRENT_SOURCE_DIR}/${MINGW_PATH}/bin/make.bat @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MinGWConfig.cmake DESTINATION ${CMAKE_INSTALL_PREFIX})
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.sha256 b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.sha256
new file mode 100644
index 00000000..fe7f0962
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.sha256
@@ -0,0 +1 @@
+bb1f1a0b35b3d96bf9c15092da8ce969a84a134f7b08811292fbc9d84d48c65d
diff --git a/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.txt b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.txt
new file mode 100644
index 00000000..3fddb030
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/depends/windows/mingw/mingw.txt
@@ -0,0 +1 @@
+mingw http://mirrors.kodi.tv/build-deps/win32/msys2/msys2-base-x86_64-20161025.tar.xz
diff --git a/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/addon.xml.in b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/addon.xml.in
new file mode 100644
index 00000000..2e091d75
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/addon.xml.in
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+ ext1|ext2
+ false
+ false
+
+
+ mygame
+ Supported files: .ext1, .ext2
+
+ @PLATFORM@
+ https://github.com/kodi-game/game.libretro.mygame
+
+
diff --git a/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/language/English/strings.po b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/language/English/strings.po
new file mode 100644
index 00000000..5898de72
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/language/English/strings.po
@@ -0,0 +1,30 @@
+# game.libretro.mygame language file
+# Addon Name: game.libretro.mygame
+# Addon id: game.libretro.mygame
+# Addon Provider: libretro
+msgid ""
+msgstr ""
+"Project-Id-Version: game.libretro.mygame\n"
+"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: Kodi Translation Team\n"
+"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgctxt "#30000"
+msgid "Settings"
+msgstr ""
+
+msgctxt "#30001"
+msgid "mysetting1"
+msgstr ""
+
+msgctxt "#30002"
+msgid "mysetting2"
+msgstr ""
+
diff --git a/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/settings.xml b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/settings.xml
new file mode 100644
index 00000000..36efce1f
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/addon/game.libretro.mygame/resources/settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/tests/integration/test_data/test_template_processor/description/game.libretro.mygame.txt b/tests/integration/test_data/test_template_processor/description/game.libretro.mygame.txt
new file mode 100644
index 00000000..264e86ef
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/description/game.libretro.mygame.txt
@@ -0,0 +1 @@
+game.libretro.mygame https://github.com/kodi-game/game.libretro.mygame master
diff --git a/tests/integration/test_data/test_template_processor/description/platforms.txt b/tests/integration/test_data/test_template_processor/description/platforms.txt
new file mode 100644
index 00000000..0702cb5b
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/description/platforms.txt
@@ -0,0 +1 @@
+all
diff --git a/tests/integration/test_data/test_template_processor/summary/summary.html b/tests/integration/test_data/test_template_processor/summary/summary.html
new file mode 100644
index 00000000..1cda9913
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/summary/summary.html
@@ -0,0 +1,44 @@
+
+
+
+
+Kodi Game Addons
+
+
+
+
+
+
+
+
+
+
+
Kodi Game Addons
+
+
+
+
Icon
+
Libretro core
+
Name
+
Platform emulated
+
Version
+
License
+
Supports VFS
+
Requires GL
+
Status
+
Git Diff
+
+
+
+
+
+
+
+
diff --git a/tests/integration/test_data/test_template_processor/summary/wiki.txt b/tests/integration/test_data/test_template_processor/summary/wiki.txt
new file mode 100644
index 00000000..564425d5
--- /dev/null
+++ b/tests/integration/test_data/test_template_processor/summary/wiki.txt
@@ -0,0 +1,6 @@
+
+
+{| class="prettytable sortable plainlinks"
+! Libretro core !! Platform emulated !! Version !! License * !! Supports VFS !! Supports Rewind !! Requires GL !! Status
+|-
+|}
diff --git a/tests/integration/test_libretro_ctypes.py b/tests/integration/test_libretro_ctypes.py
index 1dc395ed..d7b100b4 100644
--- a/tests/integration/test_libretro_ctypes.py
+++ b/tests/integration/test_libretro_ctypes.py
@@ -26,33 +26,31 @@
pytestmark = [pytest.mark.integration]
-def compile_testlibrary():
+# pylint: disable=redefined-outer-name
+
+REFERENCE_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ 'test_data', os.path.splitext(os.path.basename(__file__))[0])
+
+
+def compile_testlibrary(build_dir):
""" Compile libretro_test """
- test_dir = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'test_data', os.path.splitext(os.path.basename(__file__))[0])
- test_file = os.path.join(test_dir, 'libretro_test.{}'.format(
+ test_file = os.path.join(build_dir, 'libretro_test.{}'.format(
LibretroWrapper.EXT))
- subprocess.run([os.environ.get('CMAKE', 'cmake'), test_dir], cwd=test_dir)
+ subprocess.run([os.environ.get('CMAKE', 'cmake'), REFERENCE_DIR],
+ cwd=build_dir)
subprocess.run([os.environ.get('CMAKE', 'cmake'), '--build', '.'],
- cwd=test_dir)
+ cwd=build_dir)
assert os.path.isfile(test_file)
return test_file
-def test_load_library():
+def test_load_library(tmpdir):
""" Test LibretroWrapper """
- lib = LibretroWrapper(compile_testlibrary())
+ lib = LibretroWrapper(compile_testlibrary(str(tmpdir)))
print(lib.system_info)
assert lib.system_info.name == 'libraryname'
assert lib.system_info['name'] == 'libraryname'
print(lib.variables)
assert len(lib.variables) == 2
-
- lib2 = LibretroWrapper(compile_testlibrary())
- print(lib2.system_info)
- assert lib2.system_info.name == 'libraryname'
- assert lib.system_info['name'] == 'libraryname'
- print(lib2.variables)
- assert len(lib2.variables) == 2
diff --git a/tests/integration/test_template_processor.py b/tests/integration/test_template_processor.py
new file mode 100644
index 00000000..07870df5
--- /dev/null
+++ b/tests/integration/test_template_processor.py
@@ -0,0 +1,84 @@
+# Copyright (C) 2016-2018 Christian Fetzer
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Test the Template Processor"""
+
+import filecmp
+import os
+
+import pytest
+
+from kodi_game_scripting.template_processor import TemplateProcessor, \
+ TEMPLATE_DIR
+
+pytestmark = [pytest.mark.integration]
+
+
+# pylint: disable=redefined-outer-name
+
+REFERENCE_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ 'test_data', os.path.splitext(os.path.basename(__file__))[0])
+
+
+def test_process_template(tmpdir):
+ """Test the Template Processor"""
+ data = {
+ 'game': {
+ 'name': 'mygame',
+ 'addon': 'game.libretro.mygame',
+ 'branch': 'master',
+ 'version': '2.10.3',
+ },
+ 'libretro_repo': {
+ 'branch': 'master',
+ },
+ }
+ extdata = {
+ 'system_info': {
+ 'extensions': ['ext1', 'ext2']
+ },
+ 'settings': [
+ {'id': 1, 'description': 'mysetting1',
+ 'values': ['value1', 'value2'], 'default': 'value1'},
+ {'id': 2, 'description': 'mysetting2',
+ 'values': ['value1', 'value2'], 'default': 'value2'},
+ ],
+ }
+
+ print('Template dir: file://{}'.format(TEMPLATE_DIR))
+ print('Reference dir: file://{}'.format(REFERENCE_DIR))
+ print('Test dir: file://{}'.format(tmpdir))
+
+ template_processor = TemplateProcessor()
+
+ # First generation step skips reading previously generated data.
+ # Also don't yet provide all data so that we execute more branches.
+ template_processor.process(TEMPLATE_DIR, str(tmpdir), data)
+
+ # Add more data and run generation again.
+ data.update(extdata)
+ template_processor.process(TEMPLATE_DIR, str(tmpdir), data)
+
+ # Run the generation and include data from the previously generated files.
+ template_processor.process(TEMPLATE_DIR, str(tmpdir), data)
+
+ def assert_identical(dircmp):
+ assert not dircmp.right_only and not dircmp.diff_files
+ for subdircmp in dircmp.subdirs.values():
+ assert_identical(subdircmp)
+
+ assert_identical(filecmp.dircmp(str(tmpdir), REFERENCE_DIR))
diff --git a/tests/unit/test_templateprocessor.py b/tests/unit/test_templateprocessor.py
new file mode 100644
index 00000000..a43a253b
--- /dev/null
+++ b/tests/unit/test_templateprocessor.py
@@ -0,0 +1,44 @@
+# Copyright (C) 2016-2018 Christian Fetzer
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+""" Test common utility functions """
+
+import pytest
+
+from kodi_game_scripting.template_processor import get_list, regex_replace
+
+pytestmark = [pytest.mark.unit]
+
+
+# pylint: disable=redefined-outer-name
+
+def test_getlist():
+ """ Test the get_list filter """
+ assert get_list([]) == []
+ assert get_list(None) == [None]
+ assert get_list('') == ['']
+ assert get_list('test') == ['test']
+ assert get_list(['test1', 'test2']) == ['test1', 'test2']
+
+
+def test_regexreplace():
+ """ Test the regex_replace filter """
+ assert(regex_replace('aabbcc', r'(b+)', '-\\1-')) == 'aa-bb-cc'
+
+
+def test_regexreplace_multiline():
+ """ Test the regex_replace filter with a multiline string """
+ assert(regex_replace('a\nbb\nc', r'(b+)\n', '', multiline=True)) == 'a\nc'