Skip to content

Commit

Permalink
Improved organization of xdmod-test-artifacts update code
Browse files Browse the repository at this point in the history
  • Loading branch information
tyearke committed May 31, 2017
1 parent 02cae49 commit 6b38368
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 33 deletions.
3 changes: 0 additions & 3 deletions .travis.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ elif [ "$TEST_SUITE" = "style" ]; then
fi
done
elif [ "$TEST_SUITE" = "unit" ]; then
echo "Copying test artifacts from cached mirror..."
git clone "$TEST_ARTIFACTS_MIRROR" "open_xdmod/modules/xdmod/tests/xdmod-test-artifacts"

open_xdmod/modules/xdmod/tests/runtests.sh
if [ $? != 0 ]; then
build_exit_value=2
Expand Down
13 changes: 0 additions & 13 deletions .travis.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,3 @@ source ~/.nvm/nvm.sh
nvm install "$NODE_VERSION"
nvm use "$NODE_VERSION"
npm install

# Create or update a mirror of the XDMoD test artifacts.
#
# Travis will create any directories that are set up for caching if they do
# not exist, so check if the directory has contents instead of checking for
# the existence of the directory.
if [ -n "$(ls -A "$TEST_ARTIFACTS_MIRROR")" ]; then
echo "Updating XDMoD test artifacts mirror..."
git -C "$TEST_ARTIFACTS_MIRROR" remote update
else
echo "Creating mirror of XDMoD test artifacts..."
git clone --mirror "$TEST_ARTIFACTS_SOURCE" "$TEST_ARTIFACTS_MIRROR"
fi
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ php:
env:
global:
- NODE_VERSION=6
- TEST_ARTIFACTS_SOURCE="https://github.com/ubccr/xdmod-test-artifacts.git"
- TEST_ARTIFACTS_MIRROR="$HOME/xdmod-test-artifacts.git"
- XDMOD_TEST_ARTIFACTS_MIRROR="$HOME/xdmod-test-artifacts.git"
matrix:
- TEST_SUITE=syntax
- TEST_SUITE=style
Expand All @@ -27,7 +26,7 @@ cache:
- $HOME/.npm
- $HOME/.composer/cache
- /tmp/pear/cache
- $TEST_ARTIFACTS_MIRROR
- $XDMOD_TEST_ARTIFACTS_MIRROR

# Delegate the installation step to the custom Travis installation script
install: ./.travis.install.sh
Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions open_xdmod/modules/xdmod/tests/artifacts/update-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

xdmod_test_artifacts_source="https://github.com/ubccr/xdmod-test-artifacts.git"
using_xdmod_test_artifacts_mirror="false"; [ -n "$XDMOD_TEST_ARTIFACTS_MIRROR" ] && using_xdmod_test_artifacts_mirror="true"

# Change directory to this script's directory.
cd "$(dirname $0)" || exit 1

# If using a mirror of the xdmod-test-artifacts repo, create or update it.
#
# Travis will create any directories that are set up for caching if they do
# not exist, so also check if the directory has contents.
if "$using_xdmod_test_artifacts_mirror"; then
if [ -d "$XDMOD_TEST_ARTIFACTS_MIRROR" ] && [ -n "$(ls -A "$XDMOD_TEST_ARTIFACTS_MIRROR")" ]; then
echo "Updating xdmod-test-artifacts mirror..."
git -C "$XDMOD_TEST_ARTIFACTS_MIRROR" remote update
else
echo "Creating mirror of xdmod-test-artifacts..."
git clone --mirror "$xdmod_test_artifacts_source" "$XDMOD_TEST_ARTIFACTS_MIRROR"
fi
fi

# If the xdmod-test-artifacts repo already exists locally, update it.
# Otherwise, clone it.
artifacts_dir="./xdmod-test-artifacts"
if [ -d "$artifacts_dir" ]; then
echo "Updating local xdmod-test-artifacts clone..."
git -C "$artifacts_dir" pull
else
echo "Cloning xdmod-test-artifacts into local directory..."
if "$using_xdmod_test_artifacts_mirror"; then
local_clone_source="$XDMOD_TEST_ARTIFACTS_MIRROR"
else
local_clone_source="$xdmod_test_artifacts_source"
fi
git clone "$local_clone_source" "$artifacts_dir"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
const TEST_ARTIFACT_INPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/output";
const TEST_ARTIFACT_INPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/output";

/**
* Test JSON parse errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class EtlConfigurationTest extends \PHPUnit_Framework_TestCase
{
const TEST_ARTIFACT_INPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/output";
const TEST_ARTIFACT_INPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/output";
const TMPDIR = '/tmp/xdmod-etl-configuration-test';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class Rfc6901Test extends \PHPUnit_Framework_TestCase
{
const TEST_ARTIFACT_INPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/configuration/output";
const TEST_ARTIFACT_INPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/configuration/output";

private $config = null;
private $transformer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

class DbModelTest extends \PHPUnit_Framework_TestCase
{
const TEST_ARTIFACT_INPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/dbmodel/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./xdmod-test-artifacts/xdmod/etlv2/dbmodel/output";
const TEST_ARTIFACT_INPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/dbmodel/input";
const TEST_ARTIFACT_OUTPUT_PATH = "./artifacts/xdmod-test-artifacts/xdmod/etlv2/dbmodel/output";
private $logger = null;

public function __construct()
Expand Down
7 changes: 1 addition & 6 deletions open_xdmod/modules/xdmod/tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ if [ ! -x "$phpunit" ]; then
exit 127
fi

artifacts_dir="./xdmod-test-artifacts"
if [ -d "$artifacts_dir" ]; then
git -C "$artifacts_dir" pull
else
git clone "https://github.com/ubccr/xdmod-test-artifacts.git" "$artifacts_dir"
fi
./artifacts/update-artifacts.sh

$phpunit ${PHPUNITARGS} .
exit $?

0 comments on commit 6b38368

Please sign in to comment.