Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Integrate wake-unit and remove hack #1663

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: make tarball

- name: Run Tests
run: make test && make unittest
run: make test

- name: Check Wake Formatting
run: ./bin/wake-format.native-cpp14-release --auto --dry-run
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ format:
test: wake.db
$(WAKE_ENV) ./bin/wake --in test_wake runTests

# We need to bootstrap job-cache to run the tests
unittest: all
$(WAKE_ENV) ./bin/wake --in test_wake runUnitTests

remoteCacheTests: all
$(WAKE_ENV) ./bin/wake -d -x 'testPostgres Unit'

Expand Down
5 changes: 1 addition & 4 deletions build.wake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def bootstrapTarget targetFn variant =
# Build all wake targets
def targets =
buildWake,
buildWakeUnit,
buildWakeBox,
buildFuseDaemon,
buildShim,
Expand Down Expand Up @@ -317,14 +318,10 @@ export def static _: Result Path Error =
| getJobOutput

from test_wake import topic wakeTestBinary
from test_wake import topic wakeUnitTestBinary

publish wakeTestBinary =
defaultWake, Nil

publish wakeUnitTestBinary =
buildWakeUnit, Nil

def defaultWake Unit =
require Pass wakeVisible = doInstall "tmp" "default"

Expand Down
98 changes: 0 additions & 98 deletions tests/tests.wake
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ from wake import _
# If tests/ is used externally, the topic is empty and the invoking wake is tested instead.
export topic wakeTestBinary: Unit => Result (Pair String (List Path)) Error

# We need to handle the fact that sometimes tests are invoked from within /tests
# and sometimes they're invoked from outside of /tests. Additionally only when
# we have access to build_wake in our test environment can we figure out how
# to build the wake unit tests that we want to run. Since test_wake cannot depend
# on build_wake we instead make a topic that build_wake can publish to. This topic
# will be empty if your workspace starts in /tests but have the proper function
# in it if you start from one directory out. This means we can just have this test
# fail if it isn't run from the proper place. It's hacky but it works around
# the way we test currently.
export topic wakeUnitTestBinary: (variant: Pair String String) => Result (List Path) Error

def wakeToTestDir Unit = match (subscribe wakeTestBinary)
buildTestWake, Nil ->
require Pass (Pair path visible) = buildTestWake Unit
Expand All @@ -44,17 +33,6 @@ def wakeToTestDir Unit = match (subscribe wakeTestBinary)
Nil -> Pass (Pair "{wakePath}" Nil)
_ -> Fail (makeError "Two wake binaries declared for testing!")

def wakeUnitToTest Unit =
require buildWakeUnit, Nil = subscribe wakeUnitTestBinary
else failWithError "wake-unit binary not found"

require Pass wakeUnitLst = buildWakeUnit (Pair "native-cpp14-release" "native-c11-release")

require Some result = head wakeUnitLst
else failWithError "wake-unit binary not found"

Pass result

def showDiff (expect: String) (actual: String): Result Unit Error =
require Pass expectFile = writeTempFile "diff.expect" expect
else failWithError "Unable to write expect file"
Expand Down Expand Up @@ -135,82 +113,6 @@ export def runTests (cmdline: List String): Result String Error =

Pass "All {len tests | str} tests completed successfully."

export def runUnitTests _: Result Unit Error =
def testDirectory = "{@here}/wake-unit"

require Pass testScript = source "{testDirectory}/unit-test.sh"

def testName =
testDirectory
| replace `^${quote @here}/` ""

def readFile list = match list
Some file ->
require Pass content = read file

Pass (Some content)
None -> Pass None

require Pass expectedStdout =
source "{testDirectory}/stdout"
| getPass
| readFile

require Pass expectedStderr =
source "{testDirectory}/stderr"
| getPass
| readFile

require Pass visibleFiles = sources testDirectory `.*`

def inTestDir path = relative testDirectory path

require Pass wakeUnitBin = wakeUnitToTest Unit

def testJob =
makeExecPlan
("./{testScript.getPathName.inTestDir}", wakeUnitBin.getPathName.inTestDir, Nil)
(wakeUnitBin, visibleFiles)
| setPlanDirectory testDirectory
| setPlanLabel "testing: {testName}"
| setPlanStdout logNever
| setPlanStderr logNever
| setPlanShare False
| runJobWith localRunner

def removeCarriageReturns = replace `\r` ""

require Pass jobStdout =
testJob.getJobFailedStdout
| rmap removeCarriageReturns

require Pass jobStderr =
testJob.getJobFailedStderr
| rmap removeCarriageReturns

require Pass _ = match testJob.isJobOk
True -> Pass Unit
False ->
def _ = println jobStderr

Fail (makeError "Test failed ({format testJob.getJobStatus}). See above for details")

require Pass _ = match expectedStderr
Some x if x ==* jobStderr -> Pass Unit
None -> Pass Unit
Some _ ->
def _ = println jobStderr

Fail (makeError "Unexpected standard error. See above for details")

match expectedStdout
Some x if x ==* jobStdout -> Pass Unit
None -> Pass Unit
_ ->
def _ = println jobStdout

Fail (makeError "Unexpected standard output. See above for details")

def runTest (testScript: Path): Result Unit Error =
def shouldPass =
testScript
Expand Down
19 changes: 19 additions & 0 deletions tests/wake-unit/pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash

set -e

function cleanup {
rm -rf job_cache_test
rm -rf .job_cache_test
rm -rf job_cache_test2
rm -rf .job_cache_test2
}
trap cleanup EXIT

WAKE_UNIT="${1}/wake-unit"

TERM=xterm-256color script --return --quiet -c "$WAKE_UNIT --no-color --tag threaded" /dev/null

# We run the tests *twice* so that shared caching can run without a clean slate
TERM=xterm-256color script --return --quiet -c "$WAKE_UNIT --no-color --tag threaded" /dev/null > /dev/null

13 changes: 0 additions & 13 deletions tests/wake-unit/unit-test.sh

This file was deleted.

1 change: 1 addition & 0 deletions wake.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mkdir -p %{buildroot}/var/cache/wake
/usr/bin/wake-rsc-tool
/usr/bin/wake-format
/usr/bin/job-cache
/usr/bin/wake-unit
/usr/lib/wake
/usr/share/wake
%dir /var/cache/wake
Expand Down
Loading