Skip to content

Commit ca2ef28

Browse files
committed
判断travis环境
1 parent f2171fa commit ca2ef28

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

qiniu/resumable_io.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function Qiniu_Rio_Mkblock($self, $host, $reader, $size) // => ($blkputRet, $err
4141
if (is_resource($reader)) {
4242
$body = fread($reader, $size);
4343
if ($body === false) {
44-
$err = Qiniu_NewError(0, 'fread failed');
44+
$err = new Qiniu_Error(0, 'fread failed');
4545
return array(null, $err);
4646
}
4747
} else {
@@ -51,7 +51,7 @@ function Qiniu_Rio_Mkblock($self, $host, $reader, $size) // => ($blkputRet, $err
5151
}
5252
}
5353
if (strlen($body) != $size) {
54-
$err = Qiniu_NewError(0, 'fread failed: unexpected eof');
54+
$err = new Qiniu_Error(0, 'fread failed: unexpected eof');
5555
return array(null, $err);
5656
}
5757

@@ -81,7 +81,6 @@ function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra) // => ($putRet, $e
8181
$ctxs []= $prog['ctx'];
8282
}
8383
$body = implode(',', $ctxs);
84-
var_dump($ctxs);
8584

8685
return Qiniu_Client_CallWithForm($self, $url, $body, 'application/octet-stream');
8786
}
@@ -120,6 +119,8 @@ function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra) // => ($putRet,
120119
while ($uploaded < $fsize) {
121120
$tried = 0;
122121
$tryTimes = ($putExtra->TryTimes > 0) ? $putExtra->TryTimes : 1;
122+
$blkputRet = null;
123+
$err = null;
123124
if ($fsize < $uploaded + QINIU_RIO_BLOCK_SIZE) {
124125
$bsize = $fsize - $uploaded;
125126
} else {
@@ -136,6 +137,10 @@ function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra) // => ($putRet,
136137
if ($err !== null) {
137138
return array(null, $err);
138139
}
140+
if ($blkputRet === null ) {
141+
$err = new Qiniu_Error(0, "rio: uploaded without ret");
142+
return array(null, $err);
143+
}
139144
$uploaded += $bsize;
140145
$progresses []= $blkputRet;
141146
}
@@ -148,7 +153,7 @@ function Qiniu_Rio_PutFile($upToken, $key, $localFile, $putExtra) // => ($putRet
148153
{
149154
$fp = fopen($localFile, 'rb');
150155
if ($fp === false) {
151-
$err = Qiniu_NewError(0, 'fopen failed');
156+
$err = new Qiniu_Error(0, 'fopen failed');
152157
return array(null, $err);
153158
}
154159

tests/RioTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function testMockReader()
2626

2727
public function testPut()
2828
{
29+
if (getTestEnv() == "travis") {
30+
return;
31+
}
2932
$key = 'testRioPut' . getTid();
3033
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
3134

@@ -50,6 +53,9 @@ public function testPut()
5053

5154
public function testLargePut()
5255
{
56+
if (getTestEnv() == "travis") {
57+
return;
58+
}
5359
$key = 'testRioLargePut' . getTid();
5460
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
5561

tests/RsUtilsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public function setUp()
1616

1717
public function testRput()
1818
{
19+
if (getTestEnv() == "travis") {
20+
return;
21+
}
1922
$key = 'tmp/testRput' . getTid();
2023
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
2124

@@ -35,6 +38,9 @@ public function testRput()
3538

3639
public function testRputFile()
3740
{
41+
if (getTestEnv() == "travis") {
42+
return;
43+
}
3844
$key = 'tmp/testRputFile' . getTid();
3945
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
4046

tests/bootstrap.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
$secretKey = getenv("QINIU_SECRET_KEY");
99

1010
$tid = getenv("TRAVIS_JOB_NUMBER");
11+
12+
$testEnv = getenv("QINIU_TEST_ENV");
13+
1114
if (!empty($tid)) {
12-
$pid = getmypid();
15+
$pid = getmypid();
1316
$tid = strstr($tid, ".");
14-
$tid .= "." . $pid;
17+
$tid .= "." . $pid;
1518
}
1619

1720
function initKeys() {
@@ -26,6 +29,11 @@ function getTid() {
2629
return $tid;
2730
}
2831

32+
function getTestEnv() {
33+
global $testEnv;
34+
return $testEnv;
35+
}
36+
2937
class MockReader
3038
{
3139
private $off = 0;

0 commit comments

Comments
 (0)