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

Smoketests work on macos #15

Merged
merged 5 commits into from
Jun 23, 2023
Merged
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
10 changes: 10 additions & 0 deletions test/lib.include
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ spacetime_publish() {
set -e
return "$RESULT_CODE"
}

fsed() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i.sed_bak "$@"
rm -f rm *.sed_bak
else
sed -i "$@"
fi
}

10 changes: 5 additions & 5 deletions test/tests/autoinc1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source "./test/lib.include"
do_test() {
echo "RUNNING TEST FOR VALUE: $1"
create_project

cat > "${PROJECT_PATH}/src/lib.rs" << EOF
use spacetimedb::{println, spacetimedb};

Expand All @@ -38,12 +38,12 @@ pub fn say_hello() {
}
EOF

sed -i "s/REPLACE_VALUE/$1/g" "${PROJECT_PATH}/src/lib.rs"
run_test cargo run publish --project-path "$PROJECT_PATH" --clear-database
fsed "s/REPLACE_VALUE/$1/g" "${PROJECT_PATH}/src/lib.rs"

run_test cargo run publish --project-path "$PROJECT_PATH" --clear-database -d -s
[ "1" == "$(grep -c "reated new database" "$TEST_OUT")" ]
IDENT="$(grep "reated new database" "$TEST_OUT" | awk 'NF>1{print $NF}')"

run_test cargo run call "$IDENT" add '["Robert", 1]'
run_test cargo run call "$IDENT" add '["Julie", 2]'
run_test cargo run call "$IDENT" add '["Samantha", 3]'
Expand Down
8 changes: 4 additions & 4 deletions test/tests/autoinc2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source "./test/lib.include"
do_test() {
echo "RUNNING TEST FOR VALUE: $1"
create_project

cat > "${PROJECT_PATH}/src/lib.rs" << EOF
use spacetimedb::{println, spacetimedb};

Expand Down Expand Up @@ -46,12 +46,12 @@ pub fn say_hello() {
}
EOF

sed -i "s/REPLACE_VALUE/$1/g" "${PROJECT_PATH}/src/lib.rs"
fsed "s/REPLACE_VALUE/$1/g" "${PROJECT_PATH}/src/lib.rs"

run_test cargo run publish --project-path "$PROJECT_PATH" --clear-database
[ "1" == "$(grep -c "reated new database" "$TEST_OUT")" ]
IDENT="$(grep "reated new database" "$TEST_OUT" | awk 'NF>1{print $NF}')"

run_test cargo run call "$IDENT" update '["Robert", 2]'
run_test cargo run call "$IDENT" add_new '["Success"]'
if run_test cargo run call "$IDENT" add_new '["Failure"]' ; then
Expand Down