File: ignore.php

package info (click to toggle)
watchman 4.9.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,992 kB
  • sloc: cpp: 27,459; python: 6,538; java: 3,404; php: 3,257; ansic: 2,803; javascript: 1,116; makefile: 671; ruby: 364; sh: 124; xml: 102; lisp: 4
file content (107 lines) | stat: -rw-r--r-- 2,624 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/* Copyright 2012-present Facebook, Inc.
 * Licensed under the Apache License, Version 2.0 */

class ignoreTestCase extends WatchmanTestCase {
  function testIgnoreGit() {
    $dir = new WatchmanDirectoryFixture();
    $root = $dir->getPath();
    mkdir("$root/.git");
    mkdir("$root/.git/objects");
    mkdir("$root/.git/objects/pack");
    touch("$root/foo");

    $this->watch($root);
    // prove that we don't see pack in .git as we crawl
    $this->assertFileList($root, array(
      '.git',
      '.git/objects',
      'foo'
    ));

    // And prove that we aren't watching deeply under .git
    touch("$root/.git/objects/dontlookatme");
    $this->assertFileList($root, array(
      '.git',
      '.git/objects',
      'foo'
    ));
  }

  function testInvalidIgnore() {
    $dir = new WatchmanDirectoryFixture();
    $root = $dir->getPath();

    $bad = array(
      array('ignore_vcs' => 'lemon'),
      array('ignore_vcs' => array('foo', 123))
    );

    foreach ($bad as $cfg) {
      file_put_contents("$root/.watchmanconfig", json_encode($cfg));
      $res = $this->watch($root, false);

      $this->assertRegex(
        "/unable to resolve root .*: ignore_vcs must be an array of strings/",
        idx($res, 'error')
      );
    }
  }

  function testIgnoreOverlapVCSIgnore() {
    $dir = new WatchmanDirectoryFixture();
    $root = $dir->getPath();

    $cfg = array(
      'ignore_dirs' => array('.hg'),
    );
    file_put_contents("$root/.watchmanconfig", json_encode($cfg));
    mkdir("$root/.hg");

    $this->watch($root);
    $this->assertFileList($root, array('.watchmanconfig'));
    touch("$root/foo");
    $this->assertFileList($root, array('.watchmanconfig', 'foo'));
  }

  function testIgnoreGeneric() {
    $dir = new WatchmanDirectoryFixture();
    $root = $dir->getPath();

    $cfg = array(
      'ignore_dirs' => array('build')
    );
    file_put_contents("$root/.watchmanconfig", json_encode($cfg));

    mkdir("$root/build");
    mkdir("$root/build/lower");
    mkdir("$root/builda");
    touch("$root/foo");
    touch("$root/build/bar");
    touch("$root/buildfile");
    touch("$root/build/lower/baz");
    touch("$root/builda/hello");

    $this->watch($root);
    $this->assertFileList($root, array(
      '.watchmanconfig',
      'builda',
      'builda/hello',
      'buildfile',
      'foo',
    ));

    touch("$root/build/lower/dontlookatme");
    touch("$root/build/orme");
    touch("$root/buil");
    $this->assertFileList($root, array(
      '.watchmanconfig',
      'buil',
      'builda',
      'builda/hello',
      'buildfile',
      'foo',
    ));

  }
}