diff --git a/README.md b/README.md index 66f1328..c5fffd4 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,12 @@ mysqldump my_civi_db | bzip2 > databases/4.2.3-my_civi_db.sql.bz2 This is not strictly required. If you want to create private test-cases, you can store them anywhere and follow your own naming convention. + +### Standalone Test Cases + +The standard test snapshots do not work on Standalone, as they do not +contain the required DB state for a Standalone system. + +As such, a separate library of Standalone specific snapshots has been +created in "databases_standalone" directory. This will be used automatically +by civicrm-upgrade-test when running against a Standalone build. diff --git a/bin/civicrm-upgrade-examples b/bin/civicrm-upgrade-examples index 7e8d896..af49664 100755 --- a/bin/civicrm-upgrade-examples +++ b/bin/civicrm-upgrade-examples @@ -28,7 +28,7 @@ function help($error = NULL) { if ($error) { fwrite(STDERR, $error); } - echo "usage: $prog ...\n"; + echo "usage: $prog (--snapshot-library ) ...\n"; echo "\n"; echo " examples:\n"; echo " /var/foo.sql.gz A specific file\n"; @@ -46,12 +46,18 @@ function main($args) { return 1; } - $files = array(); - $examples = UpgradeExamples::instance(); + $files = []; + $searchArgs = []; + // default value. may be overridden by a --snapshot-library arg + $snapshotLibrary = 'databases'; + while (!empty($args)) { $arg = array_shift($args); - if ($arg[0] === '-') { + if ($arg === '--snapshot-library') { + $snapshotLibrary = array_shift($args); + } + elseif ($arg[0] === '-') { help("Unrecognized option: $arg\n"); return 2; } @@ -62,7 +68,7 @@ function main($args) { $files[] = $arg; } elseif ($arg[0] === '@' || strpos($arg, '*')) { - $files = array_merge($files, $examples->find($arg)); + $searchArgs[] = $arg; } else { help("Unrecognized argument or missing file: $arg\n"); @@ -70,6 +76,12 @@ function main($args) { } } + $examples = UpgradeExamples::instance($snapshotLibrary); + + foreach ($searchArgs as $searchArg) { + $files = array_merge($files, $examples->find($searchArg)); + } + $files = $examples->sortFilesByVer(array_unique($files)); foreach ($files as $file) { echo "$file\n"; diff --git a/bin/civicrm-upgrade-test b/bin/civicrm-upgrade-test index e3cdbdd..a5993d6 100755 --- a/bin/civicrm-upgrade-test +++ b/bin/civicrm-upgrade-test @@ -125,8 +125,15 @@ while [ -n "$1" ]; do esac done +CIVICRM_UF=$( cv --cwd="$WEB_ROOT" ev 'echo CIVICRM_UF;' ) + echo "Identify files: [$DATABASE_EXPRS]" -DATABASE_FILES=$(eval php "$SCRIPT_DIR/civicrm-upgrade-examples" $DATABASE_EXPRS) +if [[ "$CIVICRM_UF" == "Standalone" ]]; then + echo "Using 'databases_standalone' snapshot library for Standalone" + DATABASE_FILES=$(eval php "$SCRIPT_DIR/civicrm-upgrade-examples" --snapshot-library databases_standalone $DATABASE_EXPRS) +else + DATABASE_FILES=$(eval php "$SCRIPT_DIR/civicrm-upgrade-examples" $DATABASE_EXPRS) +fi if [ $? -ne 0 ]; then echo "Failed to evaluate expression \"$1\" => $DATABASE_FILES" >> /dev/stderr exit 1 diff --git a/databases_standalone/5.77.0-standalone.mysql.bz2 b/databases_standalone/5.77.0-standalone.mysql.bz2 new file mode 100644 index 0000000..c12812f Binary files /dev/null and b/databases_standalone/5.77.0-standalone.mysql.bz2 differ diff --git a/src/UpgradeExamples.php b/src/UpgradeExamples.php index 0bd1466..ba285b9 100644 --- a/src/UpgradeExamples.php +++ b/src/UpgradeExamples.php @@ -8,10 +8,8 @@ class UpgradeExamples { * * @return \Civi\UpgradeTest\UpgradeExamples */ - public static function instance(): UpgradeExamples { - static $instance; - $instance = $instance ?: new UpgradeExamples(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'databases'); - return $instance; + public static function instance(string $basePath = 'databases'): UpgradeExamples { + return new UpgradeExamples(dirname(__DIR__) . DIRECTORY_SEPARATOR . $basePath); } /**