ci(tests): add test framework (#1603)

This commit is contained in:
ReenigneArcher
2024-03-24 19:52:24 -04:00
committed by GitHub
parent 934f81182a
commit 89e8b9628c
43 changed files with 1519 additions and 136 deletions

View File

@@ -7,7 +7,7 @@ pkgrel=1
pkgdesc="@PROJECT_DESCRIPTION@"
arch=('x86_64' 'aarch64')
url=@PROJECT_HOMEPAGE_URL@
license=('GPL3')
license=('GPL-3.0-only')
install=sunshine.install
depends=('avahi'
@@ -31,16 +31,21 @@ depends=('avahi'
'numactl'
'openssl'
'opus'
'python'
'udev')
checkdepends=('doxygen'
'graphviz')
makedepends=('boost'
'cmake'
'gcc12'
'git'
'make'
'nodejs'
'npm')
optdepends=('cuda: Nvidia GPU encoding support'
'libva-mesa-driver: AMD GPU encoding support'
'intel-media-driver: Intel GPU encoding support')
'intel-media-driver: Intel GPU encoding support'
'xorg-server-xvfb: Virtual X server for headless testing')
provides=('sunshine')
@@ -57,6 +62,9 @@ build() {
export BUILD_VERSION="@GITHUB_BUILD_VERSION@"
export COMMIT="@GITHUB_COMMIT@"
export CC=gcc-12
export CXX=g++-12
export CFLAGS="${CFLAGS/-Werror=format-security/}"
export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"
@@ -72,6 +80,14 @@ build() {
make -C build
}
check() {
export CC=gcc-12
export CXX=g++-12
cd "${srcdir}/build/tests"
./test_sunshine --gtest_color=yes
}
package() {
make -C build install DESTDIR="$pkgdir"
}

View File

@@ -34,6 +34,8 @@ build-options:
prepend-ld-library-path: /usr/lib/sdk/vala/lib
modules:
- "org.flatpak.Builder.BaseApp/xvfb.json"
- name: boost
disabled: false
buildsystem: simple
@@ -341,6 +343,7 @@ modules:
- -DSUNSHINE_ENABLE_DRM=ON
- -DSUNSHINE_ENABLE_CUDA=ON
- -DSUNSHINE_BUILD_FLATPAK=ON
- -DTESTS_ENABLE_PYTHON_TESTS=OFF
sources:
- type: git
url: "@GITHUB_CLONE_URL@"
@@ -358,3 +361,7 @@ modules:
's%/app/bin/sunshine%flatpak run dev.lizardbyte.sunshine\nExecStop=flatpak kill dev.lizardbyte.sunshine%g'
/app/share/sunshine/systemd/user/sunshine.service
- install -D $FLATPAK_BUILDER_BUILDDIR/packaging/linux/flatpak/scripts/* /app/bin
run-tests: true
test-rule: "" # empty to disable
test-commands:
- xvfb-run tests/test_sunshine --gtest_color=yes

View File

@@ -31,13 +31,19 @@ post-fetch {
system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive"
}
# https://guide.macports.org/chunked/reference.dependencies.html
depends_build-append port:npm9 \
port:pkgconfig
depends_lib port:avahi \
port:curl \
port:libopus \
port:miniupnpc
port:miniupnpc \
port:python311 \
port:py311-pip
depends_test port:doxygen \
port:graphviz
boost.version 1.81
@@ -62,3 +68,9 @@ notes-append "Run @PROJECT_NAME@ by executing 'sunshine <path to user config>',
notes-append "The config file will be created if it doesn't exist."
notes-append "It is recommended to set a location for the apps file in the config."
notes-append "See our documentation at 'https://docs.lizardbyte.dev/projects/sunshine/en/v@PROJECT_VERSION@/' for further info."
test.run yes
test.dir ${build.dir}/tests
test.target ""
test.cmd ./test_sunshine
test.args --gtest_color=yes

View File

@@ -11,26 +11,28 @@ class @PROJECT_NAME@ < Formula
depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "node" => :build
depends_on "pkg-config" => :build
depends_on "curl"
depends_on "miniupnpc"
depends_on "node"
depends_on "openssl"
depends_on "opus"
def install
args = %W[
-DBUIld_WERROR=ON
-DBUILD_WERROR=ON
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
-DSUNSHINE_ASSETS_DIR=sunshine/assets
-DSUNSHINE_BUILD_HOMEBREW=ON
-DTESTS_ENABLE_PYTHON_TESTS=OFF
]
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
cd "build" do
system "make", "-j"
system "make", "install"
bin.install "tests/test_sunshine"
end
end
@@ -54,9 +56,10 @@ class @PROJECT_NAME@ < Formula
test do
# test that the binary runs at all
output = shell_output("#{bin}/sunshine --version").strip
puts output
system "#{bin}/sunshine", "--version"
# TODO: add unit tests
# run the test suite
# cannot build tests with python tests because homebrew destroys the source directory
system "#{bin}/test_sunshine", "--gtest_color=yes"
end
end