diff --git a/.gitignore b/.gitignore index 93d848dfb..981541515 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ npm-debug.log /tags /atom-shell/ docs/output +spec/fixtures/evil-files/ diff --git a/spec/fixtures/evil-files/a_file_with_utf8.txt b/spec/fixtures/evil-files/a_file_with_utf8.txt deleted file mode 100644 index a811bd702..000000000 --- a/spec/fixtures/evil-files/a_file_with_utf8.txt +++ /dev/null @@ -1 +0,0 @@ -I am evil because there's a UTF-8 character right here: ă diff --git a/spec/fixtures/evil-files/file with spaces.txt b/spec/fixtures/evil-files/file with spaces.txt deleted file mode 100644 index 140c7bf61..000000000 --- a/spec/fixtures/evil-files/file with spaces.txt +++ /dev/null @@ -1 +0,0 @@ -I am evil because there are spaces in my name diff --git "a/spec/fixtures/evil-files/goddam\nnewlines" "b/spec/fixtures/evil-files/goddam\nnewlines" deleted file mode 100644 index 00c5620b8..000000000 --- "a/spec/fixtures/evil-files/goddam\nnewlines" +++ /dev/null @@ -1 +0,0 @@ -I am evil because there's a newline in my name diff --git "a/spec/fixtures/evil-files/quote\".txt" "b/spec/fixtures/evil-files/quote\".txt" deleted file mode 100644 index 5e51d8e20..000000000 --- "a/spec/fixtures/evil-files/quote\".txt" +++ /dev/null @@ -1 +0,0 @@ -I am evil because there's a " in my filename. Why you do that!? \ No newline at end of file diff --git a/spec/fixtures/evil-files/utfă.md b/spec/fixtures/evil-files/utfă.md deleted file mode 100644 index 782a5bf5a..000000000 --- a/spec/fixtures/evil-files/utfă.md +++ /dev/null @@ -1 +0,0 @@ -I am evil because there's a UTF-8 character in my name diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index 36dd6dbe0..652b36400 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -3,6 +3,7 @@ fstream = require 'fstream' Project = require '../src/project' {_, fs} = require 'atom' path = require 'path' +platform = require './spec-helper-platform' BufferedProcess = require '../src/buffered-process' describe "Project", -> @@ -394,13 +395,20 @@ describe "Project", -> matches = matches.concat(result.matches) runs -> - expect(paths.length).toBe 5 - matches.forEach (match) -> expect(match.matchText).toEqual 'evil' - 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 - expect(path.basename(paths[4])).toBe "utfa\u0306.md" + _.each(matches, (m) -> expect(m.matchText).toEqual 'evil') + + if platform.isWindows() + expect(paths.length).toBe 3 + expect(paths[0]).toMatch /a_file_with_utf8.txt$/ + expect(paths[1]).toMatch /file with spaces.txt$/ + expect(path.basename(paths[2])).toBe "utfa\u0306.md" + else + expect(paths.length).toBe 5 + 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 + expect(path.basename(paths[4])).toBe "utfa\u0306.md" it "ignores case if the regex includes the `i` flag", -> results = [] diff --git a/spec/spec-helper-platform.coffee b/spec/spec-helper-platform.coffee new file mode 100644 index 000000000..db0198e12 --- /dev/null +++ b/spec/spec-helper-platform.coffee @@ -0,0 +1,38 @@ +path = require 'path' +fsUtils = require '../src/fs-utils' + +{_} = require 'atom' + +## Platform specific helpers +module.exports = + # Public: Returns true if being run from within Windows + isWindows: -> + !!process.platform.match /^win/ + + # Public: Some files can not exist on Windows filesystems, so we have to + # selectively generate our fixtures. + # + # Returns nothing. + generateEvilFiles: -> + evilFilesPath = path.join(__dirname, 'fixtures', 'evil-files') + fsUtils.remove(evilFilesPath) if fsUtils.exists(evilFilesPath) + fsUtils.mkdirSync(evilFilesPath) + + if (@isWindows()) + filenames = [ + "a_file_with_utf8.txt", + "file with spaces.txt", + "utfa\u0306.md" + ] + else + filenames = [ + "a_file_with_utf8.txt", + "file with spaces.txt", + "goddam\nnewlines", + "quote\".txt", + "utfa\u0306.md" + ] + + for filename in filenames + fd = fsUtils.writeFileSync(path.join(evilFilesPath, filename), 'evil file!', flag: 'w') + diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 72778f421..18c1b8b9d 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -12,8 +12,11 @@ Project = require '../src/project' Editor = require '../src/editor' TokenizedBuffer = require '../src/tokenized-buffer' pathwatcher = require 'pathwatcher' +platform = require './spec-helper-platform' clipboard = require 'clipboard' +platform.generateEvilFiles() + atom.themes.loadBaseStylesheets() atom.themes.requireStylesheet '../static/jasmine'