Page MenuHomePhabricator

Flow tests are leaving lci_* temporary files behind on integration slaves
Closed, ResolvedPublic

Description

-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 01:24 lci_h3YpdY
-rw-------  1 jenkins-slave jenkins-slave  925 Jan 29 01:07 lci_hDtwL7
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  3 08:23 lci_haksZj
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  3 12:51 lci_i1VOsA
-rw-------  1 jenkins-slave jenkins-slave  925 Jan 30 01:53 lci_i9JFrQ
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  2 20:53 lci_iGK3Dy
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  2 20:29 lci_iN1t2Y
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  3 00:29 lci_iOteoW
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  6 00:52 lci_iPeA2N
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 12:40 lci_iTG0tL
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 18:22 lci_ieGO3r
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 02:38 lci_igfYPb
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 01:48 lci_ih6SfW
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 15:49 lci_ijfEu6
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 01:14 lci_iukzmw
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 11:57 lci_iyjkOK
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 22:41 lci_j1ZjqR
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 16:16 lci_j2tB5s
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  3 23:20 lci_j5YTzc
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  4 15:13 lci_j62zmD
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 05:11 lci_j8jOaK
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 09:31 lci_jGmwjq
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  9 20:35 lci_jME8ov
-rw-------  1 jenkins-slave jenkins-slave  925 Jan 30 02:02 lci_jTiM0V
-rw-------  1 jenkins-slave jenkins-slave  839 Feb  3 08:11 lci_jiOC6a
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  5 08:05 lci_jjyFip
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  9 13:55 lci_jmyBLY
-rw-------  1 jenkins-slave jenkins-slave  925 Feb  6 13:40 lci_k52dKS
$ cat lci_yN7Qfn 
<?php return function ($in, $debugopt = 1) {
    $cx = Array(
        'flags' => Array(
            'jstrue' => false,
            'jsobj' => false,
            'spvar' => true,
            'prop' => false,
            'method' => false,
            'mustlok' => false,
            'debug' => $debugopt,
        ),
        'helpers' => Array(),
        'blockhelpers' => Array(),
        'hbhelpers' => Array(            'ifCond' => 'Flow\TemplateHelper::ifCond',
),
        'scopes' => Array($in),
        'sp_vars' => Array(),

    );
    return ''.LCRun3::hbch($cx, 'ifCond', Array(Array(((is_array($in) && isset($in['foo'])) ? $in['foo'] : null),'or',((is_array($in) && isset($in['bar'])) ? $in['bar'] : null)),Array()), $in, function($cx, $in) {return 'Works';}).'';
}

Event Timeline

Krinkle raised the priority of this task from to Needs Triage.
Krinkle updated the task description. (Show Details)
Krinkle added a subscriber: Krinkle.

That comes from the lightncandy third party libraries which Flows uses for HTML templating. In mediawiki/vendor.git

vendor$ git grep --show-function -n lci_ 
zordius/lightncandy/src/lightncandy.php=798=    public static function prepare($php, $tmpDir = null) {
zordius/lightncandy/src/lightncandy.php:806:            $fn = tempnam($tmpDir, 'lci_');

The optional second parameter is the temp directory it could be passed wfTempDir(). There is only two invocations, both in tests:

Flow$ git grep -n --show-function Lightncandy::prepare
tests/phpunit/TemplateHelperTest.php=35=        public function testIfCond() {
tests/phpunit/TemplateHelperTest.php:37:                $renderer = Lightncandy::prepare( $code );
tests/phpunit/TemplateHelperTest.php:44:                $renderer2 = Lightncandy::prepare( $code2 );

Note the method is marked as deprecated by upstream README and they recommend to:

$phpStr = LightnCandy::compile($template)

# Replace:
$renderer = LightnCandy::prepare($phpStr);

# with:
file_put_contents($php_inc, $phpStr);
$renderer = include($php_inc);

Assuming the files are small enough (less than 2MB), you could even use php://memory and skip the file system hit.

Change 198757 had a related patch set uploaded (by Krinkle):
Implement global-set-env, global-setup, global-teardown

https://gerrit.wikimedia.org/r/198757

Change 198757 merged by jenkins-bot:
Implement global-set-env, global-setup, global-teardown

https://gerrit.wikimedia.org/r/198757

Krinkle claimed this task.

MediaWiki jobs now have a scoped $TMPDIR that is cleared out after each build.