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

Add plugin support. #941

Merged
merged 6 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 20 additions & 2 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ else

mkdir -p /sytest
tar -C /sytest --strip-components=1 -xf sytest.tar.gz

if [ -n "$PLUGIN" ]; then
mkdir /sytest/plugins
echo "--- Downloading plugins for sytest"
IFS=':'; for plugin in $PLUGIN; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be called PLUGINS, if it's going to support more than one plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I thought of the PATH var while writing it not sure why that is not called PATHS, but PLUGINS makes more sense. Will change that.

wget -q https://github.com/$plugin/archive/master.tar.gz -O plugin.tar.gz || {
valkum marked this conversation as resolved.
Show resolved Hide resolved
echo "Failed to download plugin: $plugin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we write this (to stdout rather than stderr) and then carry on with mkdir and tar anyway? seems like we should exit instead? or just let set -e handle it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this. Yeah we should exit there with sending the msg to stderr.

}
mkdir -p /sytest/plugins/$plugin
tar -C /sytest/plugins/$plugin --strip-components=1 -xf plugin.tar.gz
done
fi
fi

echo "--- Preparing sytest for ${SYTEST_TARGET}"
Expand All @@ -51,6 +63,12 @@ elif [ -x "/sytest/docker/${SYTEST_TARGET}_sytest.sh" ]; then
exec "/sytest/docker/${SYTEST_TARGET}_sytest.sh" "$@"

else
echo "sytest runner script for ${SYTEST_TARGET} not found" >&2
exit 1
PLUGIN_RUNNER=$(find /sytest/plugins/ -type f -exec test -x {} \; -name "${SYTEST_TARGET}_sytest.sh" -print)
valkum marked this conversation as resolved.
Show resolved Hide resolved
if [ -n PLUGIN_RUNNER ]; then
exec ${PLUGIN_RUNNER} "$@"

else
valkum marked this conversation as resolved.
Show resolved Hide resolved
echo "sytest runner script for ${SYTEST_TARGET} not found" >&2
exit 1
fi
fi
8 changes: 7 additions & 1 deletion run-tests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Data::Dump qw( pp );
use File::Basename qw( basename );
use File::Spec::Functions qw( catdir );
use Getopt::Long qw( :config no_ignore_case gnu_getopt );
use IO::Socket::SSL;
use List::Util 1.33 qw( first all any maxstr max );
Expand All @@ -34,17 +35,22 @@
: undef;
});

my $plugin_dir = $ENV{"SYTEST_PLUGINS"} || "plugins"; # Read plugin dir from env var SYTEST_PLUGINS or fallback to plugins
richvdh marked this conversation as resolved.
Show resolved Hide resolved
my @plugins = grep { -d } glob(catdir($plugin_dir, "*", "*")); # Read all plugins/<author>/<plugin>
valkum marked this conversation as resolved.
Show resolved Hide resolved
my @lib_dirs = map { catdir($_, "lib") } @plugins;

use Module::Pluggable
sub_name => "output_formats",
search_path => [ "SyTest::Output" ],
search_dirs => \@lib_dirs,
require => 1;

use Module::Pluggable
sub_name => "homeserver_factories",
search_path => [ "SyTest::HomeserverFactory" ],
search_dirs => \@lib_dirs,
require => 1;


binmode(STDOUT, ":utf8");

our $WANT_TLS = 1; # This is shared with the test scripts
Expand Down