Commit 21d1c4c2 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Merge branch '23-add-behaviour-tests-for-configuration' into 'main'

Add behaviour tests for configuration

Closes #23

See merge request !33
parents 6150ae5f 7e886499
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ Build Images:
  trigger:
    include:
    - project: dom/project-templates
      ref: f7997d0d
      file: /pipeline-templates/build-image.yml
    strategy: depend

+2 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ repos:
  - id: check-for-squash
  - id: copyright-notice
    exclude: ^data/|^scripts/(compile-|install-)
    args: [--min-size=1000]
  - id: protect-first-parent

- repo: https://github.com/pre-commit/pygrep-hooks
@@ -93,4 +94,4 @@ repos:
    args: ["--python-version=3.9"]
    additional_dependencies:
    - types-requests
    - behave-utils ~=0.3.2
    - behave-utils ~=0.4.1
+16 −6
Original line number Diff line number Diff line
@@ -39,10 +39,14 @@ to the container, however:

- Unlike the way most configuration systems treat environment variables, 
  they do not overwrite options provided in the configuration files unless 
  the files are specifically written to honour the environment variables.
  the files are specifically written to honour the environment variables, 
  for instance by using the "+=" operator to append to arrays.

- For array options the value provided in the environment variable will 
  become the first item (index 0).
- For array options the value provided will be split on whitespace. 
  Unfortunately at the moment there is no way to escape or quote whitespace 
  within items.  If you find yourself needing to add items with whitespace, 
  consider using configuration files instead, which are interpreted with 
  Bash, or one of the [convenience files](#convenience-files).


Convenience Files
@@ -55,6 +59,10 @@ options are optional plain text files listing additional entries (one per
line) to append to the [**PLUGINS**](#plugins), [**THEMES**](#themes) and 
[**LANGUAGES**](#languages) option arrays respectively.

> **Note:** Every line in these files MUST be correctly terminated in the Unix 
> style (with a line-feed character). Please pay special attention to the final 
> line as some text editors do not correctly terminate them.


Options
-------
@@ -147,7 +155,7 @@ the missing language pack will be silently ignored.
**Required**: no\
**Default**: /etc/wordpress/languages.txt

The path to a file containing lines to append to 
The path to a plain text file containing lines to append to 
[**LANGUAGES**](#languages).

### PLUGINS
@@ -165,7 +173,8 @@ be the latest stable available in the wordpress.org registry.
**Required**: no\
**Default**: /etc/wordpress/plugins.txt

The path to a file containing lines to append to [**PLUGINS**](#plugins).
The path to a plain text file containing lines to append to 
[**PLUGINS**](#plugins).

### PHP_DIRECTIVES

@@ -307,7 +316,8 @@ latest stable available in the wordpress.org registry.
**Required**: no\
**Default**: /etc/wordpress/themes.txt

The path to a file containing lines to append to [**THEMES**](#themes).
The path to a plain text file containing lines to append to 
[**THEMES**](#themes).

### WP_CONFIGS

+15 −3
Original line number Diff line number Diff line
@@ -305,6 +305,18 @@ run_background_cron()
	exec -a wp-cron /bin/bash <<<run_cron
)& }

readlines()
{
	declare -n ARRAY=$1
	while IFS=$'\r\n' read line; do
		ARRAY+=( "$line" )
	done
	if [[ "$line" ]]; then
		echo >&2 "WARNING: unterminated line in" `readlink /proc/self/fd/0`
		ARRAY+=( "$line" )
	fi
}


mkdir -p ${CONFIG_DIR}
cd ${CONFIG_DIR}
@@ -313,13 +325,13 @@ for file in **/*.conf; do
done

if [[ -e ${PLUGINS_LIST:=${CONFIG_DIR}/plugins.txt} ]]; then
	PLUGINS+=( $(<"${PLUGINS_LIST}") )
	readlines PLUGINS <"${PLUGINS_LIST}"
fi
if [[ -e ${THEMES_LIST:=${CONFIG_DIR}/themes.txt} ]]; then
	THEMES+=( $(<"${THEMES_LIST}") )
	readlines THEMES <"${THEMES_LIST}"
fi
if [[ -e ${LANGUAGES_LIST:=${CONFIG_DIR}/languages.txt} ]]; then
	LANGUAGES+=( $(<"${LANGUAGES_LIST}") )
	readlines LANGUAGES <"${LANGUAGES_LIST}"
fi

declare -a extra_args
+1 −0
Original line number Diff line number Diff line
this-plugin-does-not-exist
Loading