diff options
author | neoninteger | 2019-06-14 23:18:18 +0930 |
---|---|---|
committer | neoninteger | 2019-06-14 23:18:18 +0930 |
commit | 884ccf7086039ca94a339560c590938ae6731b2f (patch) | |
tree | 1b682f351248cc4c7f8acff3ce27ed32e68038d2 | |
parent | 0d9f982386e2e4ed97284662f4bec6ba74662dd1 (diff) | |
download | aur-884ccf7086039ca94a339560c590938ae6731b2f.tar.gz |
Add test suite to build process
* The check() function will now do the following: create a PostgreSQL database
cluster, start a PostgreSQL server, create a role and database in the cluster
for Turtl to use, initialize the database and upload directory for the Turtl
server, start the Turtl server as a background job, run the core-rs tests,
shut down the Turtl and SQL servers and clean up after itself.
* For most commands, the standard output is either silenced with command line
flags or is redirected to /dev/null, to show only errors that occur during
the process.
* This of course requires you to have turtl-server installed.
* Please note that this package creates a release build during the build()
step, whereas in order to run the tests, a debug build has to be made. This
will result in the program being built twice - if this is unacceptable you
can run makepkg with --nocheck to skip running the test suites. This will
also remove the dependency on turtl-server.
-rw-r--r-- | .SRCINFO | 3 | ||||
-rw-r--r-- | PKGBUILD | 42 |
2 files changed, 44 insertions, 1 deletions
@@ -6,13 +6,14 @@ pkgbase = turtl-core-rs arch = i686 arch = x86_64 license = GPL3 + checkdepends = turtl-server makedepends = rust depends = libsodium depends = openssl-1.0 source = https://github.com/turtl/core-rs/archive/774fa361d021d9ef5237d32d09515ab7b2a32ad2.tar.gz source = vars.mk sha256sums = 71c1caf3aeb6245040abb0ee063b574dd6ece6314c60edabbe4299a11df49b68 - sha256sums = c4e7469d1a080786b71618bc812cf038a7c70881641f06cb8ae7f2d76de08e3c + sha256sums = 8dd67ffa28f833baa88c57ecabcc0c5e020d53b5a5516034478a0883be29193d pkgname = turtl-core-rs @@ -8,6 +8,7 @@ url="https://github.com/turtl/core-rs" license=("GPL3") depends=("libsodium" "openssl-1.0") makedepends=("rust") +checkdepends=("turtl-server") # Note: Turtl core-rs is versioned but not with Git tags or releases, the only # way to download a specific core-rs version is using a commit hash that @@ -28,6 +29,47 @@ build() { make release } +check() { + export TURTL_DB_CONNSTR="postgres://turtl:turtl@localhost:5432/turtl" + export TURTL_UPLOADS_LOCAL="$PWD/turtl-uploads" + + echo "- Creating PostgreSQL database cluster..." + mkdir turtl-db turtl-uploads + initdb -D turtl-db -A trust > /dev/null + + echo "- Starting PostgreSQL server..." + pg_ctl start -D turtl-db -o '-c unix_socket_directories=/tmp' > /dev/null + + echo "- Creating role/database for Turtl server..." + psql -q -h /tmp -d postgres -c "CREATE USER turtl WITH PASSWORD 'turtl'" + psql -q -h /tmp -d postgres -c "CREATE DATABASE turtl" + + echo "- Initializing Turtl server database/upload directory..." + bash -c "cd /usr/share/webapps/turtl && scripts/init-db.sh" > /dev/null + bash -c "cd /usr/share/webapps/turtl && node tools/populate-test-data.js" > /dev/null + + echo "- Starting Turtl server..." + node /usr/share/webapps/turtl/server.js > /dev/null & + sleep 2 + + echo "- Generating core-rs configuration..." + cd "core-rs-${_commithash}" + sed '/^ endpoint: /c\ endpoint: "http://localhost"' config.yaml.default > config.yaml + + echo "- Running core-rs tests..." + make test + + echo "- Shutting down Turtl server..." + cd .. + kill %1 + + echo "- Shutting down PostgreSQL server..." + pg_ctl stop -D turtl-db > /dev/null + + echo "- Cleaning up..." + rm -rf turtl-db turtl-uploads "core-rs-${_commithash}/config.yaml" +} + package() { cd "core-rs-${_commithash}" install -Dm 755 target/release/libturtl_core.so -t "${pkgdir}/usr/lib" |