-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle single suffixes as well as arrays
Refs #23
- Loading branch information
1 parent
dce442d
commit 552cc42
Showing
3 changed files
with
71 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/* Copyright 2014-present Facebook, Inc. | ||
* Licensed under the Apache License, Version 2.0 */ | ||
|
||
class SuffixGeneratorTestCase extends WatchmanTestCase { | ||
function testGeneratorExpr() { | ||
$dir = PhutilDirectoryFixture::newEmptyFixture(); | ||
$root = realpath($dir->getPath()); | ||
|
||
touch("$root/foo.c"); | ||
mkdir("$root/subdir"); | ||
touch("$root/subdir/bar.txt"); | ||
|
||
$this->watch($root); | ||
|
||
$res = $this->watchmanCommand('query', $root, array( | ||
'expression' => array('true'), | ||
'fields' => array('name'), | ||
'suffix' => 'c' | ||
)); | ||
$this->assertEqual(array('foo.c'), $res['files']); | ||
|
||
$res = $this->watchmanCommand('query', $root, array( | ||
'expression' => array('true'), | ||
'fields' => array('name'), | ||
'suffix' => array('c','txt') | ||
)); | ||
sort($res['files']); | ||
$this->assertEqual(array('foo.c', 'subdir/bar.txt'), $res['files']); | ||
|
||
|
||
$res = $this->watchmanCommand('query', $root, array( | ||
'expression' => array('true'), | ||
'fields' => array('name'), | ||
'suffix' => array('a' => 'b') | ||
)); | ||
$this->assertEqual( | ||
'failed to parse query: \'suffix\' must be a '. | ||
'string or an array of strings', | ||
$res['error'] | ||
); | ||
|
||
} | ||
} | ||
|
||
// vim:ts=2:sw=2:et: | ||
|