Files
SpacetimeDB/test/lib.include
T
John Detter 0b0c533830 Smoketests run in parallel (#49)
* Working on improving commands that use identities

* Fix lints

* Reverted file that shouldn't have changed

* Found and fixed all other todos

* Addressed more CLI TODOs

* Fixes for formatting issues

* Set names of identities

* Set name of identities + clippy

* Small fix

* Added the start of a doc comment, switching over to another PR

* Fixed tests that needed to be updated

* Addressed more feedback and fixed several clippy issues

* Small fix

* Apply suggestions from code review

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Added more doc comments

* Addressing more feedback

* Fixed really old bug in SpacetimeDB

* Tests to verify new functionality

* Fix clippy lints

* Email during identity creation is optional

* Some work

* Getting smoketests working on mac

* All tests are passing except known failing tests

* Working on parallel smoketests

* Fixed some bugs in saving configs that was preventing this from working

* Fixes required for parallel tests

* Tests are working in parallel

* Pruned changes

* retab

* re-retab

* retab the lib file

* Cargo profile for building more quickly

* I have to rebase on another PR

* smoketest fixes

* create_project and reset_project are now the same thing, removed
create_project

* More fixes

* Removed print statement

* Small fix

* Another fix

* Tons of improvements to the smoketests

* Have to rebase on master

* Small fixes

* More progress

* Finally working correctly!

* Apparently we're missing this

* Enable command output

* Listing installed targets

* Clean before building

* What is going on

* Something super wonky going on

* Another test

* Skip building containers for now

* Small fix

* Test using cargo instead

* Changed workflow a bit

* CI is stuck

* Small fix

* Another fix

* Try cargo run instead of building spacetime CLI

* Removed workflow step

* Fixing all of the tests

* Identity test

* Tests should finally be working

* Enable debug

* Remove spacetime from path

* Another try

* Logic fix

* Another fix

* Another fix

* Working now?

* Another fix

* Finally working again

* Adding github containers back in

* CI fix

* Use SpacetimeDB Large Runner

* Updated test to get more output

* Changed 0ms to 10ms to improve parallel test stability

* Removed unused logs

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Removed unnecessary reset_project

* Removed reset_config where its not needed

* Reset template

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-08-01 23:17:03 +02:00

73 lines
1.3 KiB
Bash

#!/bin/bash
# Runs a test with the assumption that it will return a zero result code
run_test() {
set +e
"$@" > "$TEST_OUT" 2>&1
RESULT=$?
cat "$TEST_OUT"
set -e
return "$RESULT"
}
# Runs a test with the assumption that it will return a non-zero result code
run_fail_test() {
if "$@" > "$TEST_OUT" 2>&1 ; then
cat "$TEST_OUT"
return 1
fi
cat "$TEST_OUT"
return 0
}
# This resets the spacetime config for a new test run
reset_config() {
SPACETIME_CONFIG_FILE="$(mktemp)"
export SPACETIME_CONFIG_FILE
cp "$RESET_SPACETIME_CONFIG" "$SPACETIME_CONFIG_FILE"
}
# This deletes the project from the previous test run
reset_project() {
PROJECT_PATH="$(mktemp -d)"
rmdir "$PROJECT_PATH"
cp -rp "$RESET_PROJECT_PATH" "$PROJECT_PATH"
export PROJECT_PATH
}
random_string() {
if [[ "$OSTYPE" == "darwin"* ]]; then
echo $RANDOM | md5 -q | head -c 20
else
echo $RANDOM | md5sum | head -c 20
fi
}
spacetime_publish() {
RETURN_DIR=$PWD
cd "$SPACETIME_DIR"
set +e
run_test spacetime publish "$@"
RESULT_CODE=$?
cd "$RETURN_DIR" || exit 1
set -e
return "$RESULT_CODE"
}
fsed() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i.sed_bak "$@"
rm -f rm *.sed_bak
else
sed -i "$@"
fi
}
restart_docker() {
docker-compose stop node
docker-compose start node
sleep 10
}
# vim: noexpandtab tabstop=4 shiftwidth=4