Skip to content

Commit

Permalink
CI on AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
hnw committed Jul 18, 2017
1 parent f968d48 commit d6b9c4f
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 16 deletions.
62 changes: 62 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '{branch}.{build}'

install:
- cmd: choco feature enable -n=allowGlobalConfirmation
- cmd: cinst wget
- cmd: mkdir C:\projects\php-timecop\bin

environment:
PROJECT_NAME: php-timecop
PROJECT_DIR: C:\projects\php-timecop
PHP_SRC_DIR: C:\projects\php-src
TEST_PHP_EXECUTABLE: C:\projects\php-timecop\bin\php.exe
REPORT_EXIT_STATUS: 1
NO_INTERACTION: 1

build_script:
- cmd: >-
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
git clone https://github.com/php/php-src %PHP_SRC_DIR%
cd %PHP_SRC_DIR%
git checkout PHP-7.1
wget http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip
7z x -y php-sdk-binary-tools-20110915.zip -oC:\projects\php-sdk
C:\projects\php-sdk\bin\phpsdk_setvars.bat
mkdir %PHP_SRC_DIR%\ext\%PROJECT_NAME%
xcopy %PROJECT_DIR% %PHP_SRC_DIR%\ext\%PROJECT_NAME% /s /e /y
wget http://windows.php.net/downloads/php-sdk/deps-7.1-vc14-x86.7z
7z x -y deps-7.1-vc14-x86.7z -o%PHP_SRC_DIR%
buildconf.bat
configure.bat --disable-all --enable-phar --enable-json --enable-hash --enable-ctype --enable-filter --enable-tokenizer --enable-zip --with-iconv --with-openssl --with-dom --with-libxml --enable-cli --enable-zts --enable-timecop=shared --with-config-file-scan-dir=%PROJECT_DIR%\bin\modules.d --with-prefix=%PROJECT_DIR%\bin --with-php-build=deps
nmake
nmake install
copy php.ini-development %PROJECT_DIR%\bin\php.ini
mkdir %PROJECT_DIR%\bin\modules.d
echo extension=php_timecop.dll >> %PROJECT_DIR%\bin\modules.d\php.ini
test_script:
- cmd: >-
cd %PROJECT_DIR%
dir bin\ext
%PROJECT_DIR%\bin\php.exe %PHP_SRC_DIR%\run-tests.php --show-diff
exit /b %errorlevel%
5 changes: 5 additions & 0 deletions php_timecop.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ extern zend_module_entry timecop_module_entry;
#include "TSRM.h"
#endif

#ifndef PHP_WIN32
#include <time.h>
#else
#include "win32/time.h"
#endif

#include "Zend/zend_interfaces.h"
#include "tc_timeval.h"

Expand Down
6 changes: 3 additions & 3 deletions tests/core_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ timecop.func_override=0
<?php
$dt1 = new DateTime("1970-01-01 00:00:00.900 GMT");
timecop_travel($dt1);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt2 =new TimecopDateTime();

if (class_exists("DateTimeImmutable")) {
$dt3 = new DateTimeImmutable("1970-01-01 09:00:00.900 GMT");
timecop_travel($dt3);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt4 =new TimecopDateTime();
} else {
$dt3 = new DateTime("1970-01-01 01:00:00.900");
Expand All @@ -28,7 +28,7 @@ if (class_exists("DateTimeImmutable")) {

$dt5 = new TimecopDateTime("2040-01-01 00:00:00.900 GMT");
timecop_travel($dt5);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
if (PHP_INT_SIZE === 8) {
$dt6 =new TimecopDateTime();
} else {
Expand Down
6 changes: 4 additions & 2 deletions tests/core_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ timecop.func_override=0
$dt1 = new TimecopDateTime("1970-01-01 00:00:00.900 GMT");
timecop_travel($dt1);
timecop_scale(10);
usleep(111000); // 1ms margin
usleep(130000); // 20ms margin
$dt2 =new TimecopDateTime();

timecop_travel(new TimecopDateTime("1970-01-01 00:00:02 GMT"));
timecop_scale(20);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt3 =new TimecopDateTime();
var_dump($dt2->format("Y-m-d H:i:s"));
var_dump($dt3->format("Y-m-d H:i:s"));
Expand Down
6 changes: 3 additions & 3 deletions tests/core_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ date.timezone=America/Los_Angeles
<?php
$dt1 = new DateTime("1970-01-01 00:00:00.900 GMT");
Timecop::travel($dt1);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt2 =new TimecopDateTime();

if (class_exists("DateTimeImmutable")) {
$dt3 = new DateTimeImmutable("1970-01-01 09:00:00.900 GMT");
Timecop::travel($dt3);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt4 =new TimecopDateTime();
} else {
$dt3 = new DateTime("1970-01-01 01:00:00.900");
Expand All @@ -27,7 +27,7 @@ if (class_exists("DateTimeImmutable")) {

$dt5 = new TimecopDateTime("2040-01-01 00:00:00.900 GMT");
Timecop::travel($dt5);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
if (PHP_INT_SIZE === 8) {
$dt6 =new TimecopDateTime();
} else {
Expand Down
6 changes: 4 additions & 2 deletions tests/core_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ date.timezone=America/Los_Angeles
$dt1 = new TimecopDateTime("1970-01-01 00:00:00.900 GMT");
Timecop::travel($dt1);
Timecop::scale(10);
usleep(111000); // 1ms margin
usleep(130000); // 20ms margin
$dt2 =new TimecopDateTime();

Timecop::travel(new TimecopDateTime("1970-01-01 00:00:02 GMT"));
Timecop::scale(20);
usleep(101000); // 1ms margin
usleep(120000); // 20ms margin
$dt3 =new TimecopDateTime();
var_dump($dt2->format("Y-m-d H:i:s"));
var_dump($dt3->format("Y-m-d H:i:s"));
Expand Down
2 changes: 1 addition & 1 deletion timecop_php5.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static int timecop_class_override_clear(TSRMLS_D)
{
const struct timecop_override_class_entry *p;
zend_class_entry **pce_orig, *ce_orig;
zend_function *zf_orig, *zf_ovrd, *zf_save;
zend_function *zf_orig;

p = &(timecop_override_class_table[0]);
while (p->orig_class != NULL) {
Expand Down
10 changes: 5 additions & 5 deletions timecop_php7.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ static int timecop_class_override_clear()
{
const struct timecop_override_class_entry *p;
zend_class_entry *ce_orig;
zend_function *zf_orig, *zf_ovrd, *zf_save;
zend_function *zf_orig;

p = &(timecop_override_class_table[0]);
while (p->orig_class != NULL) {
Expand Down Expand Up @@ -706,7 +706,7 @@ static int update_request_time(zend_long unixtime)

static int restore_request_time()
{
zval *server_vars, *request_time, orig_request_time;
zval *server_vars;

server_vars = zend_hash_str_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER")-1);
if (Z_TYPE(TIMECOP_G(orig_request_time)) != IS_NULL &&
Expand Down Expand Up @@ -777,7 +777,7 @@ static int get_formatted_mock_time(zval *time, zval *timezone_obj, zval *retval_
zval fixed_sec, orig_zonename;
zval now_timestamp, str_now;
tc_timeval now;
long fixed_usec;
zend_long fixed_usec;

if (TIMECOP_G(timecop_mode) == TIMECOP_MODE_REALTIME) {
ZVAL_FALSE(retval_time);
Expand Down Expand Up @@ -871,7 +871,7 @@ static int get_formatted_mock_time(zval *time, zval *timezone_obj, zval *retval_
static long get_mock_fraction(zval *time, zval *timezone_obj TSRMLS_DC)
{
zval dt1, dt2, usec1, usec2;
long fixed_usec;
zend_long fixed_usec;
zval u_str, sleep_usec;

call_php_function_with_2_params(ORIG_FUNC_NAME("date_create"), &dt1, time, timezone_obj);
Expand Down Expand Up @@ -1357,7 +1357,7 @@ static inline void _timecop_date_create(INTERNAL_FUNCTION_PARAMETERS, int immuta
static void _timecop_datetime_constructor_ex(INTERNAL_FUNCTION_PARAMETERS, zval *obj, int immutable)
{
zval orig_time, *orig_timezone = NULL;
zval fixed_time, fixed_timezone, dt, *arg1, *arg2;
zval fixed_time, fixed_timezone, *arg1, *arg2;
char *orig_time_str = NULL;
size_t orig_time_len = 0;
const char *real_func;
Expand Down

0 comments on commit d6b9c4f

Please sign in to comment.