-
Notifications
You must be signed in to change notification settings - Fork 511
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
Add test driver for srb
snapshot tests
#564
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
79dd774
Make all forks absolute
jez-stripe b5d425a
Add new test harness
jez-stripe 81430d8
Convert test/srb-rbi/empty to a test/snapshot/total
jez-stripe 9d1cf62
Add a partial test
jez-stripe 9282f0f
Use test/snapshot/driver.sh in update script
jez-stripe 9f42abd
Test in CI
jez-stripe 7e12584
Don't serialize bundler.rbi
jez-stripe caa51cf
Only make dir if non-empty
jez-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Using set -u doesn't work well with rbenv | ||
set -eo pipefail | ||
|
||
echo "--- Pre-setup" | ||
|
||
unameOut="$(uname -s)" | ||
case "${unameOut}" in | ||
Linux*) platform="linux";; | ||
Darwin*) platform="mac";; | ||
*) exit 1 | ||
esac | ||
|
||
buildkite-agent artifact download "_out_/$platform/sorbet" . | ||
|
||
mkdir -p gems/sorbet-static/libexec | ||
mv "_out_/$platform/sorbet" gems/sorbet-static/libexec | ||
chmod +x gems/sorbet-static/libexec/sorbet | ||
|
||
echo "--- setup :ruby:" | ||
|
||
pushd gems/sorbet | ||
|
||
# rbenv init has uninitialized variables | ||
eval "$(rbenv init -)" | ||
|
||
rbenv shell 2.4.3 | ||
|
||
echo "+++ tests" | ||
|
||
# TODO(jez) test/snapshot/driver.sh is not currently capable of testing the actual gem. | ||
# This currently tests that local development isn't broken. | ||
test/snapshot/driver.sh | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
task :test do | ||
Dir.glob('./test/**/*.rb').each(&method(:require)) | ||
Dir.glob('./test/**/*.rb').reject {|f| f =~ /^\.\/test\/snapshot/}.each(&method(:require)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
jez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit 1 | ||
|
||
# shellcheck disable=SC1091 | ||
source "test/snapshot/logging.sh" | ||
|
||
# ----- Option parsing ----- | ||
|
||
usage() { | ||
echo | ||
echo "Usage:" | ||
echo " $0 [options]" | ||
echo | ||
echo "Options:" | ||
echo " --verbose Be more verbose (more than just test summary)." | ||
echo " --update If a test fails, overwrite the expected with the actual" | ||
} | ||
|
||
VERBOSE= | ||
UPDATE= | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--verbose) | ||
VERBOSE="--verbose" | ||
shift | ||
;; | ||
--update) | ||
UPDATE="--update" | ||
shift | ||
;; | ||
-*) | ||
echo | ||
error "Unrecognized option: '$1'" | ||
usage | ||
exit 1 | ||
;; | ||
*) | ||
echo | ||
error "Unrecognized positional arg: '$1'" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# ----- Discover and run all the tests ----- | ||
|
||
info "Running suite: $0 $VERBOSE $UPDATE" | ||
|
||
if [ -z "$VERBOSE" ]; then | ||
info "(re-run with --verbose for more information)" | ||
else | ||
info "(--verbose mode)" | ||
fi | ||
|
||
passing_tests=() | ||
failing_tests=() | ||
|
||
for test_dir in test/snapshot/{partial,total}/*; do | ||
if test/snapshot/test_one.sh "$test_dir" $VERBOSE $UPDATE; then | ||
passing_tests+=("test/snapshot/test_one.sh $test_dir $VERBOSE $UPDATE") | ||
else | ||
failing_tests+=("test/snapshot/test_one.sh $test_dir $VERBOSE $UPDATE") | ||
fi | ||
done | ||
|
||
|
||
if [ "${#passing_tests[@]}" -ne 0 ]; then | ||
echo | ||
echo "───── Passing tests ─────" | ||
for passing_test in "${passing_tests[@]}"; do | ||
success "$passing_test" | ||
done | ||
fi | ||
|
||
if [ "${#failing_tests[@]}" -ne 0 ]; then | ||
echo | ||
echo "───── Failing tests ─────" | ||
|
||
for failing_test in "${failing_tests[@]}"; do | ||
error "$failing_test" | ||
done | ||
|
||
if [ -z "$UPDATE" ]; then | ||
echo | ||
info "If you have reason to believe these differences are ok to keep, run" | ||
info " $0 $* --update" | ||
info "or append --update to any of the commands above to update a single test." | ||
echo | ||
fi | ||
|
||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
red=$'\x1b[0;31m' | ||
green=$'\x1b[0;32m' | ||
yellow=$'\x1b[0;33m' | ||
cyan=$'\x1b[0;36m' | ||
cnone=$'\x1b[0m' | ||
|
||
# Check if FD 1 is a tty | ||
if [ -t 1 ]; then | ||
jez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
USE_COLOR=1 | ||
else | ||
USE_COLOR=0 | ||
fi | ||
|
||
# Detects whether we can add colors or not | ||
in_color() { | ||
local color="$1" | ||
shift | ||
|
||
if [ "$USE_COLOR" = "1" ]; then | ||
echo "$color$*$cnone" | ||
else | ||
echo "$*" | ||
fi | ||
} | ||
|
||
success() { echo "$(in_color "$green" "[ OK ]") $*"; } | ||
error() { echo "$(in_color "$red" "[ERR!]") $*"; } | ||
info() { echo "$(in_color "$cyan" "[ .. ]") $*"; } | ||
# Color entire warning to get users' attention (because we won't stop). | ||
warn() { in_color "$yellow" "[ .. ] $*"; } | ||
|
||
fatal() { | ||
error "$@" | ||
exit 1 | ||
} |
File renamed without changes.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you going to fix this? If not, I'd not bother with the TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to fix this in literally the next PR I write. I want to keep the TODO there because it helps me remember which things are in progress.