From d88504baef7a40bcd27d4cb171a93c7097e0015c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pola=C5=84ski?= Date: Mon, 19 Jul 2021 21:02:16 +0200 Subject: [PATCH] testing/dstask: new aport Personal task tracker designed to help you focus https://dstask.org/ --- testing/dstask/APKBUILD | 58 ++++++++++++++++++++++++++ testing/dstask/integration-tests.patch | 50 ++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 testing/dstask/APKBUILD create mode 100644 testing/dstask/integration-tests.patch diff --git a/testing/dstask/APKBUILD b/testing/dstask/APKBUILD new file mode 100644 index 00000000000..6818a0b00d9 --- /dev/null +++ b/testing/dstask/APKBUILD @@ -0,0 +1,58 @@ +# Contributor: Michał Polański +# Maintainer: Michał Polański +pkgname=dstask +pkgver=0.24.1 +pkgrel=0 +pkgdesc="Personal task tracker designed to help you focus" +url="https://dstask.org/" +license="MIT" +arch="all" +makedepends="go git" +subpackages=" + $pkgname-import:_import + $pkgname-bash-completion + $pkgname-zsh-completion + " +source="https://github.com/naggie/dstask/archive/v$pkgver/dstask-$pkgver.tar.gz + integration-tests.patch + " + +export GOPATH="$srcdir" +export GOFLAGS="$GOFLAGS -trimpath -modcacherw" + +build() { + _git_commit=$(zcat "$srcdir"/$pkgname-$pkgver.tar.gz | git get-tar-commit-id) + _build_date=$(date -u "+%Y-%m-%dT%TZ" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH}) + _ldflags="-s -w + -X github.com/naggie/dstask.GIT_COMMIT=$_git_commit + -X github.com/naggie/dstask.VERSION=$pkgver-r$pkgrel + -X github.com/naggie/dstask.BUILD_DATE=$_build_date + " + + go build -ldflags="$_ldflags" -v -o bin/dstask ./cmd/dstask + go build -ldflags="$_ldflags" -v -o bin/dstask-import ./cmd/dstask-import +} + +check() { + go test ./... +} + +_import() { + pkgdesc="Import tool for dstask" + amove usr/bin/dstask-import +} + +package() { + install -Dm755 bin/dstask "$pkgdir"/usr/bin/dstask + install -Dm755 bin/dstask-import "$pkgdir"/usr/bin/dstask-import + + install -Dm644 .dstask-bash-completions.sh \ + "$pkgdir"/usr/share/bash-completion/completions/$pkgname + install -Dm644 .dstask-zsh-completions.sh \ + "$pkgdir"/usr/share/zsh/site-functions/_$pkgname +} + +sha512sums=" +cd37e025620570d18d5fb7c47aa0e3174584828e71e58e2dc36dc7dd38bfcd5e96d8c924eb7391a2ef59b1dccdf8e514c6a64a009b20d03731378adcf6d82241 dstask-0.24.1.tar.gz +fefaca68b53248f77c09584393bb251af318704f0cf2cc79b927558a587aaaabda4d79c0d88836e1913d2697d2a3744f3fc760ab8ec4d36cb3957b61d9f68b40 integration-tests.patch +" diff --git a/testing/dstask/integration-tests.patch b/testing/dstask/integration-tests.patch new file mode 100644 index 00000000000..0f59d680eff --- /dev/null +++ b/testing/dstask/integration-tests.patch @@ -0,0 +1,50 @@ +Run integration tests against the dstask binary produced in the build step + +diff --git a/integration/main_test.go b/integration/main_test.go +index 9464ba0..05539a5 100644 +--- a/integration/main_test.go ++++ b/integration/main_test.go +@@ -4,7 +4,6 @@ import ( + "encoding/json" + "fmt" + "io/ioutil" +- "log" + "os" + "os/exec" + "testing" +@@ -13,34 +12,12 @@ import ( + "gotest.tools/assert" + ) + +-func TestMain(m *testing.M) { +- if err := compile(); err != nil { +- log.Fatalf("compile error: %v", err) +- } +- cleanup := func() { +- if err := os.Remove("dstask"); err != nil { +- log.Panic("could not remove integration test binary") +- } +- } +- +- exitCode := m.Run() +- cleanup() +- os.Exit(exitCode) +-} +- +-func compile() error { +- // We expect to execute in the ./integration directory, and we will output +- // our test binary there. +- cmd := exec.Command("go", "build", "-mod=vendor", "-o", "./dstask", "../cmd/dstask/main.go") +- return cmd.Run() +-} +- + // Create a callable closure that will run our test binary against a + // particular repository path. Any variables set in the environment will be + // passed to the test subprocess. + func testCmd(repoPath string) func(args ...string) ([]byte, *exec.ExitError, bool) { + return func(args ...string) ([]byte, *exec.ExitError, bool) { +- cmd := exec.Command("./dstask", args...) ++ cmd := exec.Command("../bin/dstask", args...) + env := os.Environ() + cmd.Env = append(env, fmt.Sprintf("DSTASK_GIT_REPO=%s", repoPath)) + output, err := cmd.Output()