2013-09-24 02:46:57 +04:00
|
|
|
temp = require 'temp'
|
|
|
|
fstream = require 'fstream'
|
2013-09-18 05:58:41 +04:00
|
|
|
Project = require '../src/project'
|
2013-09-20 00:51:53 +04:00
|
|
|
{_, fs} = require 'atom'
|
2013-06-13 02:26:09 +04:00
|
|
|
path = require 'path'
|
2013-09-18 05:58:41 +04:00
|
|
|
BufferedProcess = require '../src/buffered-process'
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe "Project", ->
|
|
|
|
beforeEach ->
|
2013-02-28 03:20:33 +04:00
|
|
|
project.setPath(project.resolve('dir'))
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2013-08-29 05:37:40 +04:00
|
|
|
describe "serialization", ->
|
2013-08-30 05:24:51 +04:00
|
|
|
deserializedProject = null
|
|
|
|
|
|
|
|
afterEach ->
|
|
|
|
deserializedProject?.destroy()
|
|
|
|
|
2013-08-29 05:37:40 +04:00
|
|
|
it "destroys unretained buffers and does not include them in the serialized state", ->
|
|
|
|
project.bufferForPath('a')
|
|
|
|
expect(project.getBuffers().length).toBe 1
|
2013-08-30 05:24:51 +04:00
|
|
|
deserializedProject = deserialize(project.serialize())
|
|
|
|
expect(deserializedProject.getBuffers().length).toBe 0
|
2013-08-29 05:37:40 +04:00
|
|
|
expect(project.getBuffers().length).toBe 0
|
|
|
|
|
2013-02-28 03:20:43 +04:00
|
|
|
describe "when an edit session is destroyed", ->
|
2012-08-28 02:36:36 +04:00
|
|
|
it "removes edit session and calls destroy on buffer (if buffer is not referenced by other edit sessions)", ->
|
2013-05-15 05:58:10 +04:00
|
|
|
editSession = project.open("a")
|
|
|
|
anotherEditSession = project.open("a")
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
expect(project.editSessions.length).toBe 2
|
|
|
|
expect(editSession.buffer).toBe anotherEditSession.buffer
|
|
|
|
|
|
|
|
editSession.destroy()
|
|
|
|
expect(project.editSessions.length).toBe 1
|
|
|
|
|
|
|
|
anotherEditSession.destroy()
|
|
|
|
expect(project.editSessions.length).toBe 0
|
|
|
|
|
2013-02-28 03:21:42 +04:00
|
|
|
describe "when an edit session is saved and the project has no path", ->
|
|
|
|
it "sets the project's path to the saved file's parent directory", ->
|
|
|
|
project.setPath(undefined)
|
|
|
|
expect(project.getPath()).toBeUndefined()
|
2013-05-15 05:58:10 +04:00
|
|
|
editSession = project.open()
|
2013-02-28 03:21:42 +04:00
|
|
|
editSession.saveAs('/tmp/atom-test-save-sets-project-path')
|
|
|
|
expect(project.getPath()).toBe '/tmp'
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.remove('/tmp/atom-test-save-sets-project-path')
|
2013-02-28 03:21:42 +04:00
|
|
|
|
2013-08-07 06:05:24 +04:00
|
|
|
describe "when an edit session is deserialized", ->
|
|
|
|
it "emits an 'edit-session-created' event and stores the edit session", ->
|
|
|
|
handler = jasmine.createSpy('editSessionCreatedHandler')
|
|
|
|
project.on 'edit-session-created', handler
|
|
|
|
|
|
|
|
editSession1 = project.open("a")
|
|
|
|
expect(handler.callCount).toBe 1
|
|
|
|
expect(project.getEditSessions().length).toBe 1
|
|
|
|
expect(project.getEditSessions()[0]).toBe editSession1
|
|
|
|
|
|
|
|
editSession2 = deserialize(editSession1.serialize())
|
|
|
|
expect(handler.callCount).toBe 2
|
|
|
|
expect(project.getEditSessions().length).toBe 2
|
|
|
|
expect(project.getEditSessions()[0]).toBe editSession1
|
|
|
|
expect(project.getEditSessions()[1]).toBe editSession2
|
|
|
|
|
2013-05-15 05:58:10 +04:00
|
|
|
describe ".open(path)", ->
|
2013-05-15 06:23:25 +04:00
|
|
|
[fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = []
|
2012-08-28 02:36:36 +04:00
|
|
|
beforeEach ->
|
2013-09-18 03:09:32 +04:00
|
|
|
absolutePath = require.resolve('./fixtures/dir/a')
|
2012-08-28 02:36:36 +04:00
|
|
|
newBufferHandler = jasmine.createSpy('newBufferHandler')
|
2013-01-05 00:45:49 +04:00
|
|
|
project.on 'buffer-created', newBufferHandler
|
2012-08-28 02:36:36 +04:00
|
|
|
newEditSessionHandler = jasmine.createSpy('newEditSessionHandler')
|
2013-01-05 00:45:49 +04:00
|
|
|
project.on 'edit-session-created', newEditSessionHandler
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2013-06-13 04:16:10 +04:00
|
|
|
fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/)
|
|
|
|
barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//)
|
2013-09-18 20:42:29 +04:00
|
|
|
project.registerOpener(fooOpener)
|
|
|
|
project.registerOpener(barOpener)
|
2013-05-15 06:23:25 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2013-09-18 20:42:29 +04:00
|
|
|
project.unregisterOpener(fooOpener)
|
|
|
|
project.unregisterOpener(barOpener)
|
2013-05-15 06:23:25 +04:00
|
|
|
|
|
|
|
describe "when passed a path that doesn't match a custom opener", ->
|
|
|
|
describe "when given an absolute path that hasn't been opened previously", ->
|
|
|
|
it "returns a new edit session for the given path and emits 'buffer-created' and 'edit-session-created' events", ->
|
|
|
|
editSession = project.open(absolutePath)
|
|
|
|
expect(editSession.buffer.getPath()).toBe absolutePath
|
|
|
|
expect(newBufferHandler).toHaveBeenCalledWith editSession.buffer
|
|
|
|
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
|
|
|
|
|
|
|
describe "when given a relative path that hasn't been opened previously", ->
|
|
|
|
it "returns a new edit session for the given path (relative to the project root) and emits 'buffer-created' and 'edit-session-created' events", ->
|
|
|
|
editSession = project.open('a')
|
|
|
|
expect(editSession.buffer.getPath()).toBe absolutePath
|
|
|
|
expect(newBufferHandler).toHaveBeenCalledWith editSession.buffer
|
|
|
|
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
|
|
|
|
|
|
|
describe "when passed the path to a buffer that has already been opened", ->
|
|
|
|
it "returns a new edit session containing previously opened buffer and emits a 'edit-session-created' event", ->
|
|
|
|
editSession = project.open(absolutePath)
|
|
|
|
newBufferHandler.reset()
|
|
|
|
expect(project.open(absolutePath).buffer).toBe editSession.buffer
|
|
|
|
expect(project.open('a').buffer).toBe editSession.buffer
|
|
|
|
expect(newBufferHandler).not.toHaveBeenCalled()
|
|
|
|
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
|
|
|
|
|
|
|
describe "when not passed a path", ->
|
|
|
|
it "returns a new edit session and emits 'buffer-created' and 'edit-session-created' events", ->
|
|
|
|
editSession = project.open()
|
|
|
|
expect(editSession.buffer.getPath()).toBeUndefined()
|
|
|
|
expect(newBufferHandler).toHaveBeenCalledWith(editSession.buffer)
|
|
|
|
expect(newEditSessionHandler).toHaveBeenCalledWith editSession
|
|
|
|
|
|
|
|
describe "when passed a path that matches a custom opener", ->
|
|
|
|
it "returns the resource returned by the custom opener", ->
|
2013-07-13 00:26:47 +04:00
|
|
|
pathToOpen = project.resolve('a.foo')
|
|
|
|
expect(project.open(pathToOpen, hey: "there")).toEqual { foo: pathToOpen, options: {hey: "there"} }
|
2013-05-15 06:23:25 +04:00
|
|
|
expect(project.open("bar://baz")).toEqual { bar: "bar://baz" }
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe ".bufferForPath(path)", ->
|
|
|
|
describe "when opening a previously opened path", ->
|
|
|
|
it "does not create a new buffer", ->
|
|
|
|
buffer = project.bufferForPath("a").retain()
|
|
|
|
expect(project.bufferForPath("a")).toBe buffer
|
|
|
|
|
|
|
|
alternativeBuffer = project.bufferForPath("b").retain().release()
|
|
|
|
expect(alternativeBuffer).not.toBe buffer
|
|
|
|
buffer.release()
|
|
|
|
|
|
|
|
it "creates a new buffer if the previous buffer was destroyed", ->
|
|
|
|
buffer = project.bufferForPath("a").retain().release()
|
|
|
|
expect(project.bufferForPath("a").retain().release()).not.toBe buffer
|
|
|
|
|
2013-05-15 06:55:14 +04:00
|
|
|
describe ".resolve(uri)", ->
|
|
|
|
describe "when passed an absolute or relative path", ->
|
|
|
|
it "returns an absolute path based on the project's root", ->
|
2013-09-18 03:09:32 +04:00
|
|
|
absolutePath = require.resolve('./fixtures/dir/a')
|
2013-05-15 06:55:14 +04:00
|
|
|
expect(project.resolve('a')).toBe absolutePath
|
|
|
|
expect(project.resolve(absolutePath + '/../a')).toBe absolutePath
|
|
|
|
expect(project.resolve('a/../a')).toBe absolutePath
|
|
|
|
|
|
|
|
describe "when passed a uri with a scheme", ->
|
|
|
|
it "does not modify uris that begin with a scheme", ->
|
|
|
|
expect(project.resolve('http://zombo.com')).toBe 'http://zombo.com'
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe ".setPath(path)", ->
|
|
|
|
describe "when path is a file", ->
|
|
|
|
it "sets its path to the files parent directory and updates the root directory", ->
|
2013-09-18 03:09:32 +04:00
|
|
|
project.setPath(require.resolve('./fixtures/dir/a'))
|
|
|
|
expect(project.getPath()).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
|
|
|
expect(project.getRootDirectory().path).toEqual path.dirname(require.resolve('./fixtures/dir/a'))
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe "when path is a directory", ->
|
|
|
|
it "sets its path to the directory and updates the root directory", ->
|
2013-09-18 05:58:41 +04:00
|
|
|
directory = fs.absolute(path.join(__dirname, 'fixtures', 'dir', 'a-dir'))
|
2013-09-18 03:09:32 +04:00
|
|
|
project.setPath(directory)
|
|
|
|
expect(project.getPath()).toEqual directory
|
|
|
|
expect(project.getRootDirectory().path).toEqual directory
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
describe "when path is null", ->
|
|
|
|
it "sets its path and root directory to null", ->
|
|
|
|
project.setPath(null)
|
|
|
|
expect(project.getPath()?).toBeFalsy()
|
|
|
|
expect(project.getRootDirectory()?).toBeFalsy()
|
|
|
|
|
|
|
|
describe ".getFilePaths()", ->
|
2013-03-08 05:48:34 +04:00
|
|
|
it "returns file paths using a promise", ->
|
2012-12-13 00:26:39 +04:00
|
|
|
paths = null
|
|
|
|
waitsForPromise ->
|
|
|
|
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(paths.length).toBeGreaterThan 0
|
|
|
|
|
2012-08-28 02:36:36 +04:00
|
|
|
it "ignores files that return true from atom.ignorePath(path)", ->
|
2013-06-13 02:26:09 +04:00
|
|
|
spyOn(project, 'isPathIgnored').andCallFake (filePath) -> path.basename(filePath).match /a$/
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2012-12-13 00:26:39 +04:00
|
|
|
paths = null
|
|
|
|
waitsForPromise ->
|
|
|
|
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
|
|
|
|
|
|
|
runs ->
|
2013-03-20 20:46:50 +04:00
|
|
|
expect(paths).not.toContain(project.resolve('a'))
|
|
|
|
expect(paths).toContain(project.resolve('b'))
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2012-12-13 06:19:21 +04:00
|
|
|
describe "when config.core.hideGitIgnoredFiles is true", ->
|
|
|
|
it "ignores files that are present in .gitignore if the project is a git repo", ->
|
2012-12-18 07:56:28 +04:00
|
|
|
config.set "core.hideGitIgnoredFiles", true
|
2013-09-18 03:09:32 +04:00
|
|
|
project.setPath(path.join(__dirname, 'fixtures', 'git', 'working-dir'))
|
2012-12-13 06:19:21 +04:00
|
|
|
paths = null
|
|
|
|
waitsForPromise ->
|
|
|
|
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
2012-12-13 00:26:39 +04:00
|
|
|
|
2013-03-13 01:42:24 +04:00
|
|
|
runs ->
|
2012-12-15 02:14:50 +04:00
|
|
|
expect(paths).not.toContain('ignored.txt')
|
|
|
|
|
2012-12-13 01:58:15 +04:00
|
|
|
describe "ignored file name", ->
|
|
|
|
ignoredFile = null
|
|
|
|
|
|
|
|
beforeEach ->
|
2013-09-18 03:09:32 +04:00
|
|
|
ignoredFile = path.join(__dirname, 'fixtures', 'dir', 'ignored.txt')
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.writeSync(ignoredFile, "")
|
2012-12-13 01:58:15 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.remove(ignoredFile)
|
2012-12-13 01:58:15 +04:00
|
|
|
|
|
|
|
it "ignores ignored.txt file", ->
|
|
|
|
paths = null
|
2013-05-16 21:51:23 +04:00
|
|
|
config.pushAtKeyPath("core.ignoredNames", "ignored.txt")
|
2012-12-13 01:58:15 +04:00
|
|
|
waitsForPromise ->
|
|
|
|
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
|
|
|
|
2012-12-13 06:19:21 +04:00
|
|
|
runs ->
|
|
|
|
expect(paths).not.toContain('ignored.txt')
|
2012-11-09 23:35:45 +04:00
|
|
|
|
2012-12-13 01:58:15 +04:00
|
|
|
describe "ignored folder name", ->
|
|
|
|
ignoredFile = null
|
|
|
|
|
|
|
|
beforeEach ->
|
2013-09-18 03:09:32 +04:00
|
|
|
ignoredFile = path.join(__dirname, 'fixtures', 'dir', 'ignored', 'ignored.txt')
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.writeSync(ignoredFile, "")
|
2012-12-13 01:58:15 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.remove(ignoredFile)
|
2012-12-13 01:58:15 +04:00
|
|
|
|
|
|
|
it "ignores ignored folder", ->
|
|
|
|
paths = null
|
2012-12-18 04:54:09 +04:00
|
|
|
config.get("core.ignoredNames").push("ignored.txt")
|
2012-12-18 05:52:20 +04:00
|
|
|
config.set("core.ignoredNames", config.get("core.ignoredNames"))
|
2012-12-13 01:58:15 +04:00
|
|
|
waitsForPromise ->
|
|
|
|
project.getFilePaths().done (foundPaths) -> paths = foundPaths
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(paths).not.toContain('ignored/ignored.txt')
|
|
|
|
|
2012-08-28 02:36:36 +04:00
|
|
|
describe ".scan(options, callback)", ->
|
|
|
|
describe "when called with a regex", ->
|
2013-09-25 03:37:01 +04:00
|
|
|
it "calls the callback with all regex results in all files in the project", ->
|
|
|
|
results = []
|
2012-08-28 02:36:36 +04:00
|
|
|
waitsForPromise ->
|
2013-09-25 03:37:01 +04:00
|
|
|
project.scan /(a)+/, (result) ->
|
|
|
|
results.push(result)
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
runs ->
|
2013-09-25 03:37:01 +04:00
|
|
|
expect(results).toHaveLength(3)
|
|
|
|
expect(results[0].filePath).toBe project.resolve('a')
|
|
|
|
expect(results[0].matches).toHaveLength(3)
|
|
|
|
expect(results[0].matches[0]).toEqual
|
2013-09-24 02:46:57 +04:00
|
|
|
matchText: 'aaa'
|
|
|
|
lineText: 'aaa bbb'
|
2013-09-25 03:37:01 +04:00
|
|
|
lineTextOffset: 0
|
2013-09-24 02:46:57 +04:00
|
|
|
range: [[0, 0], [0, 3]]
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2012-10-30 03:02:06 +04:00
|
|
|
it "works with with escaped literals (like $ and ^)", ->
|
2013-09-25 03:37:01 +04:00
|
|
|
results = []
|
2012-10-30 03:02:06 +04:00
|
|
|
waitsForPromise ->
|
2013-09-25 03:37:01 +04:00
|
|
|
project.scan /\$\w+/, (result) -> results.push(result)
|
2012-10-30 03:02:06 +04:00
|
|
|
|
|
|
|
runs ->
|
2013-09-25 03:37:01 +04:00
|
|
|
expect(results.length).toBe 1
|
2012-10-30 03:02:06 +04:00
|
|
|
|
2013-09-25 03:37:01 +04:00
|
|
|
{filePath, matches} = results[0]
|
|
|
|
expect(filePath).toBe project.resolve('a')
|
2013-09-24 02:46:57 +04:00
|
|
|
expect(matches).toHaveLength 1
|
2012-10-30 03:02:06 +04:00
|
|
|
expect(matches[0]).toEqual
|
2013-09-17 04:13:33 +04:00
|
|
|
matchText: '$bill'
|
|
|
|
lineText: 'dollar$bill'
|
2013-09-25 03:37:01 +04:00
|
|
|
lineTextOffset: 0
|
2012-10-30 03:02:06 +04:00
|
|
|
range: [[2, 6], [2, 11]]
|
|
|
|
|
2012-08-28 02:36:36 +04:00
|
|
|
it "works on evil filenames", ->
|
2013-09-18 03:09:32 +04:00
|
|
|
project.setPath(path.join(__dirname, 'fixtures', 'evil-files'))
|
2012-08-28 02:36:36 +04:00
|
|
|
paths = []
|
|
|
|
matches = []
|
|
|
|
waitsForPromise ->
|
2013-06-13 03:20:40 +04:00
|
|
|
project.scan /evil/, (result) ->
|
2013-09-25 03:37:01 +04:00
|
|
|
paths.push(result.filePath)
|
2013-09-24 02:46:57 +04:00
|
|
|
matches = matches.concat(result.matches)
|
2012-08-28 02:36:36 +04:00
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(paths.length).toBe 5
|
2013-09-24 02:46:57 +04:00
|
|
|
matches.forEach (match) -> expect(match.matchText).toEqual 'evil'
|
2012-08-28 02:36:36 +04:00
|
|
|
expect(paths[0]).toMatch /a_file_with_utf8.txt$/
|
|
|
|
expect(paths[1]).toMatch /file with spaces.txt$/
|
|
|
|
expect(paths[2]).toMatch /goddam\nnewlines$/m
|
|
|
|
expect(paths[3]).toMatch /quote".txt$/m
|
2013-06-13 02:26:09 +04:00
|
|
|
expect(path.basename(paths[4])).toBe "utfa\u0306.md"
|
2012-08-28 02:36:36 +04:00
|
|
|
|
2013-09-19 01:41:38 +04:00
|
|
|
it "ignores case if the regex includes the `i` flag", ->
|
2013-09-24 02:46:57 +04:00
|
|
|
results = []
|
2013-09-19 01:41:38 +04:00
|
|
|
waitsForPromise ->
|
2013-09-24 02:46:57 +04:00
|
|
|
project.scan /DOLLAR/i, (result) -> results.push(result)
|
2013-09-19 01:41:38 +04:00
|
|
|
|
|
|
|
runs ->
|
2013-09-24 02:46:57 +04:00
|
|
|
expect(results).toHaveLength 1
|
2013-01-09 03:24:14 +04:00
|
|
|
|
2013-04-05 19:45:00 +04:00
|
|
|
describe "when the core.excludeVcsIgnoredPaths config is truthy", ->
|
|
|
|
[projectPath, ignoredPath] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
2013-09-24 02:46:57 +04:00
|
|
|
sourceProjectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir')
|
|
|
|
projectPath = path.join(temp.mkdirSync("atom"))
|
|
|
|
|
|
|
|
writerStream = fstream.Writer(projectPath)
|
|
|
|
fstream.Reader(sourceProjectPath).pipe(writerStream)
|
|
|
|
|
|
|
|
waitsFor (done) ->
|
|
|
|
writerStream.on 'close', done
|
|
|
|
writerStream.on 'error', done
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
fs.rename(path.join(projectPath, 'git.git'), path.join(projectPath, '.git'))
|
|
|
|
ignoredPath = path.join(projectPath, 'ignored.txt')
|
|
|
|
fs.writeSync(ignoredPath, 'this match should not be included')
|
2013-04-05 19:45:00 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2013-09-24 02:46:57 +04:00
|
|
|
fs.remove(projectPath) if fs.exists(projectPath)
|
2013-04-05 19:45:00 +04:00
|
|
|
|
|
|
|
it "excludes ignored files", ->
|
|
|
|
project.setPath(projectPath)
|
|
|
|
config.set('core.excludeVcsIgnoredPaths', true)
|
2013-09-24 02:46:57 +04:00
|
|
|
resultHandler = jasmine.createSpy("result found")
|
2013-04-05 19:45:00 +04:00
|
|
|
waitsForPromise ->
|
2013-09-24 02:46:57 +04:00
|
|
|
project.scan /match/, (results) ->
|
|
|
|
resultHandler()
|
2013-04-05 19:45:00 +04:00
|
|
|
|
|
|
|
runs ->
|
2013-09-24 02:46:57 +04:00
|
|
|
expect(resultHandler).not.toHaveBeenCalled()
|
2013-04-05 19:45:00 +04:00
|
|
|
|
2013-09-17 03:11:01 +04:00
|
|
|
it "includes only files when a directory filter is specified", ->
|
2013-09-24 02:46:57 +04:00
|
|
|
projectPath = path.join(path.join(__dirname, 'fixtures', 'dir'))
|
2013-09-17 03:11:01 +04:00
|
|
|
project.setPath(projectPath)
|
|
|
|
|
|
|
|
filePath = path.join(projectPath, 'a-dir', 'oh-git')
|
|
|
|
|
|
|
|
paths = []
|
|
|
|
matches = []
|
|
|
|
waitsForPromise ->
|
|
|
|
project.scan /aaa/, paths: ['a-dir/'], (result) ->
|
2013-09-25 03:37:01 +04:00
|
|
|
paths.push(result.filePath)
|
2013-09-24 02:46:57 +04:00
|
|
|
matches = matches.concat(result.matches)
|
2013-09-17 03:11:01 +04:00
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(paths.length).toBe 1
|
|
|
|
expect(paths[0]).toBe filePath
|
|
|
|
expect(matches.length).toBe 1
|
|
|
|
|
2013-04-12 22:47:11 +04:00
|
|
|
it "includes files and folders that begin with a '.'", ->
|
|
|
|
projectPath = '/tmp/atom-tests/folder-with-dot-file'
|
2013-06-13 03:20:40 +04:00
|
|
|
filePath = path.join(projectPath, '.text')
|
2013-09-18 05:58:41 +04:00
|
|
|
fs.writeSync(filePath, 'match this')
|
2013-04-12 22:47:11 +04:00
|
|
|
project.setPath(projectPath)
|
|
|
|
paths = []
|
|
|
|
matches = []
|
|
|
|
waitsForPromise ->
|
2013-06-13 04:16:10 +04:00
|
|
|
project.scan /match this/, (result) ->
|
2013-09-25 03:37:01 +04:00
|
|
|
paths.push(result.filePath)
|
2013-09-24 02:46:57 +04:00
|
|
|
matches = matches.concat(result.matches)
|
2013-04-12 22:47:11 +04:00
|
|
|
|
|
|
|
runs ->
|
|
|
|
expect(paths.length).toBe 1
|
|
|
|
expect(paths[0]).toBe filePath
|
|
|
|
expect(matches.length).toBe 1
|
2013-04-05 19:45:00 +04:00
|
|
|
|
2013-09-25 00:36:52 +04:00
|
|
|
it "excludes values in core.ignoredNames", ->
|
|
|
|
projectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir')
|
|
|
|
ignoredNames = config.get("core.ignoredNames")
|
|
|
|
ignoredNames.push("a")
|
|
|
|
config.set("core.ignoredNames", ignoredNames)
|
|
|
|
|
|
|
|
resultHandler = jasmine.createSpy("result found")
|
2013-05-22 05:46:03 +04:00
|
|
|
waitsForPromise ->
|
2013-09-25 00:36:52 +04:00
|
|
|
project.scan /dollar/, (results) ->
|
|
|
|
console.log results
|
|
|
|
resultHandler()
|
2013-05-22 05:46:03 +04:00
|
|
|
|
|
|
|
runs ->
|
2013-09-25 00:36:52 +04:00
|
|
|
expect(resultHandler).not.toHaveBeenCalled()
|