首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Travis测试失败,但通过了本地机器。

Travis测试失败,但通过了本地机器。
EN

Stack Overflow用户
提问于 2014-01-27 23:53:41
回答 1查看 360关注 0票数 0

下面的测试从路径加载所有Markdown文件。它在本地工作,但在特拉维斯身上随机失败。有时,它会在没有任何故障的情况下通过,有时它会传递一些PHP版本。正在测试的类是这里

代码语言:javascript
复制
public function testLoadMultipleFiles()
{
    $index_content = "<h2>This is a Sub Page Index</h2>" . PHP_EOL . PHP_EOL
        . "<p>This is index.md in the 'sub' folder.</p>" . PHP_EOL . PHP_EOL
        . "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>" . PHP_EOL . PHP_EOL
        . "<p>Donec ultricies tristique nulla et mattis.</p>" . PHP_EOL. PHP_EOL
        . "<p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>" . PHP_EOL;

    $sub_page_content = "<h2>This is a Sub Page</h2>" . PHP_EOL . PHP_EOL
            . "<p>This is page.md in the 'sub' folder.</p>" . PHP_EOL . PHP_EOL
            . "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>" . PHP_EOL . PHP_EOL
            . "<p>Donec ultricies tristique nulla et mattis.</p>" . PHP_EOL . PHP_EOL
            . "<p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>". PHP_EOL;

    // Create a stub for the SomeClass class.
    $parser = $this->getMock('Michelf\MarkdownInterface', array('defaultTransform', 'transform'));

    $parser::staticExpects($this->at(0))
            ->method('defaultTransform')
            ->will($this->returnValue($index_content));

    $parser::staticExpects($this->at(1))
            ->method('defaultTransform')
            ->will($this->returnValue($sub_page_content));

    $loader = new MarkdownLoader($parser);

    $files['sub/index.md'] = array(
        'meta'    => array(
            'title'         => 'Sub Page Index'
        ),
        'content' => $index_content
    );

    $files['sub/page.md'] = array(
        'meta'    => array(
            'title'         => 'Sub Page'
        ),
        'content' => $sub_page_content
    );

    $result = $loader->load(ROOT_DIR . 'content/sub', array('md'));
    $this->assertEquals($files, $result);
}

Travis在失败的运行中显示了以下内容:

代码语言:javascript
复制
There was 1 failure:
1) Zepto\FileLoader\MarkdownLoaderTest::testLoadMultipleFiles
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     'sub/index.md' => Array (
         'meta' => Array (...)
-        'content' => '<h2>This is a Sub Page Index</h2>
+        'content' => '<h2>This is a Sub Page</h2>

-        <p>This is index.md in the 'sub' folder.</p>
+        <p>This is page.md in the 'sub' folder.</p>
@@ @@
         'meta' => Array (...)
-        'content' => '<h2>This is a Sub Page</h2>
+        'content' => '<h2>This is a Sub Page Index</h2>

-        <p>This is page.md in the 'sub' folder.</p>
+        <p>This is index.md in the 'sub' folder.</p>

         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

         <p>Donec ultricies tristique nulla et mattis.</p>

         <p>Phasellus id massa eget nisl congue blandit sit amet id ligula.</p>
         '
     )
 )
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-11 01:52:43

很抱歉拖延了很长时间。

只是猜测一下,但是您在本地使用Mac吗?

Mac按字母顺序返回列表,但在linux上文件系统以随机顺序列出文件。

在您的测试错误消息中,您可以看到每个读取的文件都得到了它所期望的相反的结果,即indexsub page,这使我相信由于目录列表而失败的测试出现了一个随机错误(当它通过文件系统时,它以正确的顺序返回这两个文件)。我不知道任何的单位,所以我不能帮助你的具体情况不幸。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21394252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档