Skip to content

Commit d7fedcf

Browse files
committed
Moved working dir for test to test/assets to fix interferences with real world installs
1 parent 5f3c78d commit d7fedcf

File tree

13 files changed

+62
-36
lines changed

13 files changed

+62
-36
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ What does php-band is :
4949
+ check the validity of the version
5050
+ if it does not exist, attempts to download the php archive from a list of prefered sites
5151
+ if the php source directory does not exist, extract it from the archive into src directory
52-
+ switches to php tource directory
53-
+ reads per-version configuration
54-
+ if not already, configures php:
52+
+ switches to php source directory
53+
+ reads per-version configuration
54+
+ if not already done or any configuration is newer that marker file, configures php:
5555
+ runs the *pre_configure_php()* function
5656
+ runs configure
5757
+ runs the *post_configure_php()* function if configure was successfull
5858
+ marks the version as configured
59-
+ if not already compiled
59+
+ if not already compiled or configuration marker file is newer than built marker
6060
+ runs the *pre_compile_php()* function
6161
+ compiles php
6262
+ runs the *post_compile_php()* function if compilation was successfull
@@ -84,7 +84,7 @@ To get it clear, look at this example of config tree:
8484

8585
php-band will use first *./config/configure-php.sh* for any version.
8686
Then if major version is 5, *./config/5/configure-php.sh* overrides the previous configuration.
87-
Then if major version is 5 and minor version is 6, *.config/5/6/configure-php.sh* overrides the previous configuration.
87+
Then if major version is 5 and minor version is 6, *.config/5/6/configure-php.sh* definitions will overrides the previous configuration.
8888
And so on ...
8989

9090
## What you can do
@@ -100,7 +100,9 @@ Its default value is defined to "--disable-all".
100100
+ *post_configure_php()* is called after a successfull php's *configure*
101101
+ *pre_compile_php()* is called before php's *make*
102102
+ *post_compile_php()* is called after a successfull php's *make*
103-
+ *post_install_php()* is called after a successfull php's *make install*
103+
+ *post_install_php()* is called after a successfull php's *make install*, usefull to create default config files
104+
105+
The pre_\* and post_\* functions are called with the working directory set to the php source directory.
104106

105107
## Readonly variables
106108

bin/php-band

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ PHP_BAND_NAME=$(basename "$0")
44
pushd "$(dirname $0)" > /dev/null
55
PHP_BAND_ROOT_DIR=$(dirname $(pwd -P))
66
popd > /dev/null
7-
PHP_BAND_ARCH_DIR=${PHP_BAND_ROOT_DIR}/archs
8-
PHP_BAND_INST_DIR=${PHP_BAND_ROOT_DIR}/inst
9-
PHP_BAND_CONFIG_DIR=${PHP_BAND_ROOT_DIR}/config
10-
PHP_BAND_SOURCE_DIR=${PHP_BAND_ROOT_DIR}/src
7+
PHP_BAND_ASSETS_DIR=${PHP_BAND_ASSETS_DIR:-$PHP_BAND_ROOT_DIR}
8+
PHP_BAND_ARCH_DIR=${PHP_BAND_ASSETS_DIR}/archs
9+
PHP_BAND_INST_DIR=${PHP_BAND_ASSETS_DIR}/inst
10+
PHP_BAND_CONFIG_DIR=${PHP_BAND_ASSETS_DIR}/config
11+
PHP_BAND_SOURCE_DIR=${PHP_BAND_ASSETS_DIR}/src
1112
# local vars
1213
php_band_command_to_run=
1314
php_band_source_archive_format="xz"

lib/core.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ php_band_build_php_source_dirname() {
7777
php_band_check_newer() {
7878
local refFile="$1"
7979
local testFile="$2"
80-
[ -f "${refFile}" ] || return
81-
[ -f "${testFile}" ] || return
80+
if [ ! -f "${refFile}" ]; then
81+
return
82+
fi
83+
if [ ! -f "${testFile}" ]; then
84+
return
85+
fi
8286
if [ "${testFile}" -nt "${refFile}" ]; then
8387
rm "${refFile}"
8488
fi
@@ -97,7 +101,6 @@ get_per_version_config() {
97101
while [ $# -gt 0 -a "$1" != "" ]; do
98102
config_dir="$config_dir/$1"
99103
if [ -f "$config_dir/${base_config_file}" ]; then
100-
echo "found config at $config_dir"
101104
source "$config_dir/${base_config_file}" $x
102105
php_band_check_newer "${refFile}" "${config_dir}/${base_config_file}"
103106
fi

test/10_core.bats

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ setup() {
5252
}
5353

5454
@test "Test config per version from main config" {
55-
local cfg="$BATS_TEST_DIRNAME/fixtures/test-config.sh"
55+
local cfg="$PHP_BAND_ASSETS_DIR/config/test-config.sh"
5656

5757
get_per_version_config "$cfg" "1" "20" "30" "RC40"
5858
assert_equals "$test_main" "test_main"
@@ -63,7 +63,7 @@ setup() {
6363
}
6464

6565
@test "Test config per uncomplete version" {
66-
local cfg="$BATS_TEST_DIRNAME/fixtures/test-config.sh"
66+
local cfg="$PHP_BAND_ASSETS_DIR/config/test-config.sh"
6767

6868
get_per_version_config "$cfg"
6969
assert_equals "$test_main" "test_main"
@@ -74,7 +74,7 @@ setup() {
7474
}
7575

7676
@test "Test config per version from specific config" {
77-
local cfg="$BATS_TEST_DIRNAME/fixtures/test-config.sh"
77+
local cfg="$PHP_BAND_ASSETS_DIR/config/test-config.sh"
7878

7979
get_per_version_config "$cfg" "10" "20" "30" "RC40"
8080
assert_equals "$test_main" "test_main"
@@ -102,3 +102,21 @@ EOF
102102
result=$(cat "$filename")
103103
assert_equals "$result" "$expected"
104104
}
105+
106+
@test "Check newer file" {
107+
local file1="${BATS_TMPDIR}/check_newer_1"
108+
local file2="${BATS_TMPDIR}/check_newer_2"
109+
touch "$file2"
110+
touch "$file1"
111+
php_band_check_newer "$file1" "$file2"
112+
[ -f "$file1" ]
113+
[ -f "$file2" ]
114+
touch "$file1"
115+
php_band_check_newer "$file1" "$file2"
116+
[ -f "$file1" ]
117+
[ -f "$file2" ]
118+
php_band_check_newer "qsddq" "$file2"
119+
[ -f "$file2" ]
120+
php_band_check_newer "$file1" "qsddq"
121+
[ -f "$file1" ]
122+
}

test/10_simple_commands.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ load test_helper
2121
}
2222

2323
@test "List installed versions of php-band when none is installed" {
24-
run bin/php-band --list-installed
24+
PHP_BAND_ASSETS_DIR=$PHP_BAND_ASSETS_DIR run bin/php-band --list-installed
2525
assert_output ""
2626
assert_status 0
2727
}
2828

2929
@test "List installed versions of php-band when some are installed" {
30-
mkdir inst/5.6.10 inst/5.6.2
31-
run bin/php-band --list-installed
30+
mkdir ${PHP_BAND_ASSETS_DIR}/inst/5.6.10 ${PHP_BAND_ASSETS_DIR}/inst/5.6.2
31+
PHP_BAND_ASSETS_DIR=$PHP_BAND_ASSETS_DIR run bin/php-band --list-installed
3232
assert_output "5.6.2
3333
5.6.10"
3434
assert_status 0

test/90_install.bats

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
load test_helper
44

55
@test "Call php-band to install an already downloaded archive" {
6-
[ ! -f "archs/php-5.6.10.tar.xz" ]
7-
cp $BATS_TEST_DIRNAME/fixtures/php-5.6.10.tar.xz archs/
8-
[ -f "archs/php-5.6.10.tar.xz" ]
9-
run bin/php-band --install 5.6.10
10-
[ -f "archs/php-5.6.10.tar.xz" ]
11-
[ -d "src/php-5.6.10" ]
12-
[ -f "src/php-5.6.10/.configured" ]
13-
[ -f "src/php-5.6.10/.built" ]
14-
[ -f "inst/5.6.10/test" ]
6+
# [ ! -f "archs/php-5.6.10.tar.xz" ]
7+
# cp $BATS_TEST_DIRNAME/fixtures/php-5.6.10.tar.xz archs/
8+
[ -f "${PHP_BAND_ASSETS_DIR}/archs/php-5.6.10.tar.xz" ]
9+
PHP_BAND_ASSETS_DIR=$PHP_BAND_ASSETS_DIR run bin/php-band --install 5.6.10
10+
[ -f "${PHP_BAND_ASSETS_DIR}/archs/php-5.6.10.tar.xz" ]
11+
[ -d "${PHP_BAND_ASSETS_DIR}/src/php-5.6.10" ]
12+
[ -f "${PHP_BAND_ASSETS_DIR}/src/php-5.6.10/.configured" ]
13+
[ -f "${PHP_BAND_ASSETS_DIR}/src/php-5.6.10/.built" ]
14+
[ -f "${PHP_BAND_ASSETS_DIR}/inst/5.6.10/test" ]
1515
}
1616

1717
@test "Call php-band to install a valid version of an existing PHP" {
1818
if [ "x$PHP_BAND_TEST_COMPILATION" = "x" ]; then
1919
skip "We only compile if PHP_BAND_TEST_COMPILATION is set"
2020
fi
21-
run bin/php-band --install 5.6.10
21+
PHP_BAND_ASSETS_DIR=$PHP_BAND_ASSETS_DIR run bin/php-band --install 5.6.10
2222
assert_line_contains "PHP 5.6.10 has been downloaded"
2323
[ -f "archs/php-5.6.10.tar.xz" ]
2424
[ -d "src/php-5.6.10" ]
2525
[ -f "src/php-5.6.10/.configured" ]
2626
[ -f "src/php-5.6.10/.built" ]
2727
[ -f "inst/5.6.10/bin/php" ]
2828
assert_status 0
29-
run inst/5.6.10/bin/php -v
29+
run ${PHP_BAND_ASSETS_DIR}/inst/5.6.10/bin/php -v
3030
assert_line_contains "php 5.6.10"
3131
assert_status 0
3232
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)