From d4366aa09e7858c7b8ec72c355d54f6494be30dd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 13:57:26 -0700 Subject: [PATCH 01/15] Pass element not jQuery object as target Previously this was passing since ctrl-z was completely unbound at this point which isn't the case on Windows. --- spec/atom-spec.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index d2e6392af..8617edef6 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -380,8 +380,8 @@ describe "the `atom` global", -> runs -> atom.packages.deactivatePackage('package-with-keymaps') - expect(atom.keymaps.findKeyBindings(keystrokes:'ctrl-z', target:$$ -> @div class: 'test-1'[0])).toHaveLength 0 - expect(atom.keymaps.findKeyBindings(keystrokes:'ctrl-z', target:$$ -> @div class: 'test-2'[0])).toHaveLength 0 + expect(atom.keymaps.findKeyBindings(keystrokes:'ctrl-z', target: ($$ -> @div class: 'test-1')[0])).toHaveLength 0 + expect(atom.keymaps.findKeyBindings(keystrokes:'ctrl-z', target: ($$ -> @div class: 'test-2')[0])).toHaveLength 0 it "removes the package's stylesheets", -> waitsForPromise -> From 5b479ad5f593948048c01ffe9cc26e4eeeca0ca2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 14:57:01 -0700 Subject: [PATCH 02/15] Use temp directory in checkoutHead specs --- spec/git-spec.coffee | 49 +++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index a412cc7d4..fd551f9b5 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -88,48 +88,37 @@ describe "Git", -> expect(repo.isPathNew(filePath)).toBeFalsy() describe ".checkoutHead(path)", -> - [path1, path2, originalPath1Text, originalPath2Text] = [] + [filePath, workingDirPath] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - path1 = require.resolve('./fixtures/git/working-dir/file.txt') - originalPath1Text = fs.readFileSync(path1, 'utf8') - path2 = require.resolve('./fixtures/git/working-dir/other.txt') - originalPath2Text = fs.readFileSync(path2, 'utf8') - - afterEach -> - fs.writeFileSync(path1, originalPath1Text) - fs.writeFileSync(path2, originalPath2Text) + workingDirPath = temp.mkdirSync('atom-working-dir') + fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + repo = new Git(workingDirPath) + filePath = path.join(workingDirPath, 'a.txt') it "no longer reports a path as modified after checkout", -> - expect(repo.isPathModified(path1)).toBeFalsy() - fs.writeFileSync(path1, '') - expect(repo.isPathModified(path1)).toBeTruthy() - expect(repo.checkoutHead(path1)).toBeTruthy() - expect(repo.isPathModified(path1)).toBeFalsy() + expect(repo.isPathModified(filePath)).toBeFalsy() + fs.writeFileSync(filePath, 'ch ch changes') + expect(repo.isPathModified(filePath)).toBeTruthy() + expect(repo.checkoutHead(filePath)).toBeTruthy() + expect(repo.isPathModified(filePath)).toBeFalsy() it "restores the contents of the path to the original text", -> - fs.writeFileSync(path1, '') - expect(repo.checkoutHead(path1)).toBeTruthy() - expect(fs.readFileSync(path1, 'utf8')).toBe(originalPath1Text) - - it "only restores the path specified", -> - fs.writeFileSync(path2, 'path 2 is edited') - expect(repo.isPathModified(path2)).toBeTruthy() - expect(repo.checkoutHead(path1)).toBeTruthy() - expect(fs.readFileSync(path2, 'utf8')).toBe('path 2 is edited') - expect(repo.isPathModified(path2)).toBeTruthy() + fs.writeFileSync(filePath, 'ch ch changes') + expect(repo.checkoutHead(filePath)).toBeTruthy() + expect(fs.readFileSync(filePath, 'utf8')).toBe '' it "fires a status-changed event if the checkout completes successfully", -> - fs.writeFileSync(path1, '') - repo.getPathStatus(path1) + fs.writeFileSync(filePath, 'ch ch changes') + repo.getPathStatus(filePath) statusHandler = jasmine.createSpy('statusHandler') repo.on 'status-changed', statusHandler - repo.checkoutHead(path1) + repo.checkoutHead(filePath) expect(statusHandler.callCount).toBe 1 - expect(statusHandler.argsForCall[0][0..1]).toEqual [path1, 0] + expect(statusHandler.argsForCall[0][0..1]).toEqual [filePath, 0] - repo.checkoutHead(path1) + repo.checkoutHead(filePath) expect(statusHandler.callCount).toBe 1 describe ".destroy()", -> From 08686ee7694ad1f5fdedbd0e1dcb48a45558bdad Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:01:16 -0700 Subject: [PATCH 03/15] Use temp directory in isPathNew/Modified specs --- spec/git-spec.coffee | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index fd551f9b5..caecb0656 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -41,17 +41,15 @@ describe "Git", -> expect(repo.isPathIgnored('b.txt')).toBeFalsy() describe ".isPathModified(path)", -> - [repo, filePath, newPath, originalPathText] = [] + [repo, filePath, newPath] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - filePath = require.resolve('./fixtures/git/working-dir/file.txt') - newPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'new-path.txt') - originalPathText = fs.readFileSync(filePath, 'utf8') - - afterEach -> - fs.writeFileSync(filePath, originalPathText) - fs.removeSync(newPath) if fs.existsSync(newPath) + workingDirPath = temp.mkdirSync('atom-working-dir') + fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + repo = new Git(workingDirPath) + filePath = path.join(workingDirPath, 'a.txt') + newPath = path.join(workingDirPath, 'new-path.txt') describe "when the path is unstaged", -> it "returns false if the path has not been modified", -> @@ -72,14 +70,14 @@ describe "Git", -> [filePath, newPath] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - filePath = require.resolve('./fixtures/git/working-dir/file.txt') - newPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'new-path.txt') + workingDirPath = temp.mkdirSync('atom-working-dir') + fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + repo = new Git(workingDirPath) + filePath = path.join(workingDirPath, 'a.txt') + newPath = path.join(workingDirPath, 'new-path.txt') fs.writeFileSync(newPath, "i'm new here") - afterEach -> - fs.removeSync(newPath) if fs.existsSync(newPath) - describe "when the path is unstaged", -> it "returns true if the path is new", -> expect(repo.isPathNew(newPath)).toBeTruthy() From 516035a82cefd75107f4870ea92298355b838cc4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:06:59 -0700 Subject: [PATCH 04/15] Add copyRepository helper --- spec/git-spec.coffee | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index caecb0656..1d592f17e 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -5,6 +5,12 @@ path = require 'path' Task = require '../src/task' describe "Git", -> +copyRepository = -> + workingDirPath = temp.mkdirSync('atom-working-dir') + fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + workingDirPath + repo = null beforeEach -> @@ -44,9 +50,7 @@ describe "Git", -> [repo, filePath, newPath] = [] beforeEach -> - workingDirPath = temp.mkdirSync('atom-working-dir') - fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) - fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + workingDirPath = copyRepository() repo = new Git(workingDirPath) filePath = path.join(workingDirPath, 'a.txt') newPath = path.join(workingDirPath, 'new-path.txt') @@ -70,9 +74,7 @@ describe "Git", -> [filePath, newPath] = [] beforeEach -> - workingDirPath = temp.mkdirSync('atom-working-dir') - fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) - fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + workingDirPath = copyRepository() repo = new Git(workingDirPath) filePath = path.join(workingDirPath, 'a.txt') newPath = path.join(workingDirPath, 'new-path.txt') @@ -86,12 +88,10 @@ describe "Git", -> expect(repo.isPathNew(filePath)).toBeFalsy() describe ".checkoutHead(path)", -> - [filePath, workingDirPath] = [] + [filePath] = [] beforeEach -> - workingDirPath = temp.mkdirSync('atom-working-dir') - fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) - fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + workingDirPath = copyRepository() repo = new Git(workingDirPath) filePath = path.join(workingDirPath, 'a.txt') From 3f3dabed41ecbf2d5694b402d3aaecde2ccc23b3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:07:14 -0700 Subject: [PATCH 05/15] Remove spec completely tested in git-utils library --- spec/git-spec.coffee | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 1d592f17e..805174004 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -125,22 +125,6 @@ copyRepository = -> repo.destroy() expect(-> repo.getShortHead()).toThrow() - describe ".getDiffStats(path)", -> - [filePath, originalPathText] = [] - - beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - filePath = require.resolve('./fixtures/git/working-dir/file.txt') - originalPathText = fs.readFileSync(filePath, 'utf8') - - afterEach -> - fs.writeFileSync(filePath, originalPathText) - - it "returns the number of lines added and deleted", -> - expect(repo.getDiffStats(filePath)).toEqual {added: 0, deleted: 0} - fs.writeFileSync(filePath, "#{originalPathText} edited line") - expect(repo.getDiffStats(filePath)).toEqual {added: 1, deleted: 1} - describe ".getPathStatus(path)", -> [filePath, originalPathText] = [] From 805c7ae301431ce78c85243d40e6f99c9f499a47 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:08:43 -0700 Subject: [PATCH 06/15] :lipstick: --- spec/git-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 805174004..a6add59b6 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -4,13 +4,13 @@ fs = require 'fs-plus' path = require 'path' Task = require '../src/task' -describe "Git", -> copyRepository = -> workingDirPath = temp.mkdirSync('atom-working-dir') fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) workingDirPath +describe "Git", -> repo = null beforeEach -> From 0524a724e11b6204f44c108a5e6939df81286e0e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:15:13 -0700 Subject: [PATCH 07/15] Move fixtures into repo --- spec/fixtures/git/working-dir/dir/b.txt | 0 spec/fixtures/git/working-dir/file.txt | 1 - spec/fixtures/git/working-dir/git.git/index | Bin 137 -> 334 bytes .../06/15f9a45968b3515e0a202530ef9f61aba26b6c | Bin 0 -> 110 bytes .../16/735fb793d7b038818219c4b8c6295346e20eef | Bin 0 -> 164 bytes .../52/f56457b6fca045ce41bb9d32e6ca79d23192af | Bin 0 -> 166 bytes .../5b/24ab4c3baadf534242b1acc220c8fa051b9b20 | Bin 0 -> 79 bytes .../66/dc9051da651c15d98d017a88658263cab28f02 | Bin 0 -> 24 bytes .../8a/9c86f1cb1f14b8f436eb91f4b052c8802ca99e | 1 + .../ec/5e386905ff2d36e291086a1207f2585aaa8920 | Bin 0 -> 50 bytes .../fe/bde178cdf35e9df6279d87aa27590c6d92e354 | Bin 0 -> 139 bytes .../ff/c8218bd2240a0cb92f6f02548d45784428349b | Bin 0 -> 28 bytes .../git/working-dir/git.git/refs/heads/master | 2 +- spec/fixtures/git/working-dir/other.txt | 1 - 14 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 spec/fixtures/git/working-dir/dir/b.txt delete mode 100644 spec/fixtures/git/working-dir/file.txt create mode 100644 spec/fixtures/git/working-dir/git.git/objects/06/15f9a45968b3515e0a202530ef9f61aba26b6c create mode 100644 spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef create mode 100644 spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af create mode 100644 spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 create mode 100644 spec/fixtures/git/working-dir/git.git/objects/66/dc9051da651c15d98d017a88658263cab28f02 create mode 100644 spec/fixtures/git/working-dir/git.git/objects/8a/9c86f1cb1f14b8f436eb91f4b052c8802ca99e create mode 100644 spec/fixtures/git/working-dir/git.git/objects/ec/5e386905ff2d36e291086a1207f2585aaa8920 create mode 100644 spec/fixtures/git/working-dir/git.git/objects/fe/bde178cdf35e9df6279d87aa27590c6d92e354 create mode 100644 spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b delete mode 100644 spec/fixtures/git/working-dir/other.txt diff --git a/spec/fixtures/git/working-dir/dir/b.txt b/spec/fixtures/git/working-dir/dir/b.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec/fixtures/git/working-dir/file.txt b/spec/fixtures/git/working-dir/file.txt deleted file mode 100644 index 66dc9051d..000000000 --- a/spec/fixtures/git/working-dir/file.txt +++ /dev/null @@ -1 +0,0 @@ -undefined \ No newline at end of file diff --git a/spec/fixtures/git/working-dir/git.git/index b/spec/fixtures/git/working-dir/git.git/index index bf35b18cd334b5611b86f4a8dc91bf08542daf34..e49f052cdef53c909897e7b1237f67226b99a7d2 100644 GIT binary patch literal 334 zcmZ?q402{*U|<4bmf(*6F+iFDMl%A%*i6}V85kOuFfcHF1xks4ClsTL!nML|ZV6$+TqmO0|XWE?!fwxj+ zL~r&oR&}H{C7;^V&&0rymYI_ZaT3fwFdFI}b2M{!{-03nzNEs%vr|8xDWuo6!bQVm xHUnpVNk(cB*r1RgS686F*cfyT6%4p8T(3{4Te)%G?c*uGx5!xBU`7Fk>(@FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT zM5uza%$!uPnzTC;0&k_th~DgFtm;T@Nt<8 literal 0 HcmV?d00001 diff --git a/spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef b/spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef new file mode 100644 index 0000000000000000000000000000000000000000..e5d8eb93c4c43d673464725fc8b80cf50c4dc69b GIT binary patch literal 164 zcmV;V09*ff0iBLX4#F@D06FIs{s72!9nwk&!I>j3a1s|HC`BbK&j-X0IL;hKlg42v z6}SnrI+=lwEE**>Q8o9z5f+Z5DKTSedqq#Ni;V87lU*uUkFvDREU9|--qc&yQlN&j zAW~q-OEq$Oug7tMojuA0_WCU8RA6=b;_XM9!=UB7NaL^u5+rFu7YODU5Z%XqKCAs- SaNC@rFK1iSS9Ndbqf9dYl}cd% literal 0 HcmV?d00001 diff --git a/spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af b/spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af new file mode 100644 index 0000000000000000000000000000000000000000..03280f17f92921347ea184b70380df75453ad75b GIT binary patch literal 166 zcmV;X09pTd0iBLZ4#FT509|v6cLAHn9};79?a~tfeOOXyO~udgt?>pfXBLx5bFHO; zkZ#i!B0$4+_CaZHT$Gw?!XQv+iIjadJj5VOG>P59LQ?~7tkgMLFMAtNI>(*hKB?%E z5nfAWNFY&W;n9Y9ffGH;1n2N7X)LfCzj*)A;Zj4nc4@AA;0n2N);kGXw1{lA>u00? U3+&kUFt>r0uDu)k00NXtOU?sL6aWAK literal 0 HcmV?d00001 diff --git a/spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 b/spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 new file mode 100644 index 0000000000000000000000000000000000000000..27cfeb8f2846ab6a1d28fdd3e1b8e2a234116992 GIT binary patch literal 79 zcmV-V0I>gf0V^p=O;s?nWH2-^Ff%bxNYpE-C}DUu_tET47q2;ccWbUIkGgT_Nl)-Z lsDiZ2oK&!yv^x_5Z>7qJ-t1+p>PT%$KDDWz2>^*!A66C=BJThI literal 0 HcmV?d00001 diff --git a/spec/fixtures/git/working-dir/git.git/objects/66/dc9051da651c15d98d017a88658263cab28f02 b/spec/fixtures/git/working-dir/git.git/objects/66/dc9051da651c15d98d017a88658263cab28f02 new file mode 100644 index 0000000000000000000000000000000000000000..8e13deb381191df69656a705ac8a197170452348 GIT binary patch literal 24 gcmb7He)a}FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT zL=yubP)NxvVt5m0k;(dB*X+?mjw~VePZ3e8Iu)SW(=u~X!6u~LnGkp@RYvq?FJo0l tYE$y5P5n$zHTfkOsYPH#|4%4(UsB=X*{Pq;6w>Qj;i6$O8vwe9Hp`8$JzxL; literal 0 HcmV?d00001 diff --git a/spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b b/spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b new file mode 100644 index 0000000000000000000000000000000000000000..919f08db877f221f674ad2aacbdf956e3f40a6af GIT binary patch literal 28 kcmb Date: Fri, 30 May 2014 15:20:57 -0700 Subject: [PATCH 08/15] Copy repository in remaining specs --- spec/git-spec.coffee | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index a6add59b6..2f6de9032 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -126,15 +126,12 @@ describe "Git", -> expect(-> repo.getShortHead()).toThrow() describe ".getPathStatus(path)", -> - [filePath, originalPathText] = [] + [filePath] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - filePath = require.resolve('./fixtures/git/working-dir/file.txt') - originalPathText = fs.readFileSync(filePath, 'utf8') - - afterEach -> - fs.writeFileSync(filePath, originalPathText) + workingDirectory = copyRepository() + repo = new Git(workingDirectory) + filePath = path.join(workingDirectory, 'file.txt') it "trigger a status-changed event when the new status differs from the last cached one", -> statusHandler = jasmine.createSpy("statusHandler") @@ -149,16 +146,13 @@ describe "Git", -> expect(statusHandler.callCount).toBe 1 describe ".getDirectoryStatus(path)", -> - [directoryPath, filePath, originalPathText] = [] + [directoryPath, filePath] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - directoryPath = path.join(__dirname, 'fixtures', 'git', 'working-dir', 'dir') - filePath = require.resolve('./fixtures/git/working-dir/dir/b.txt') - originalPathText = fs.readFileSync(filePath, 'utf8') - - afterEach -> - fs.writeFileSync(filePath, originalPathText) + workingDirectory = copyRepository() + repo = new Git(workingDirectory) + directoryPath = path.join(workingDirectory, 'dir') + filePath = path.join(directoryPath, 'b.txt') it "gets the status based on the files inside the directory", -> expect(repo.isStatusModified(repo.getDirectoryStatus(directoryPath))).toBe false @@ -170,18 +164,15 @@ describe "Git", -> [newPath, modifiedPath, cleanPath, originalModifiedPathText] = [] beforeEach -> - repo = new Git(path.join(__dirname, 'fixtures', 'git', 'working-dir')) - modifiedPath = atom.project.resolve('git/working-dir/file.txt') - originalModifiedPathText = fs.readFileSync(modifiedPath, 'utf8') - newPath = atom.project.resolve('git/working-dir/untracked.txt') - cleanPath = atom.project.resolve('git/working-dir/other.txt') + workingDirectory = copyRepository() + repo = new Git(workingDirectory) + modifiedPath = path.join(workingDirectory, 'file.txt') + newPath = path.join(workingDirectory, 'untracked.txt') + cleanPath = path.join(workingDirectory, 'other.txt') + fs.writeFileSync(cleanPath, 'Full of text') fs.writeFileSync(newPath, '') newPath = fs.absolute newPath # specs could be running under symbol path. - afterEach -> - fs.writeFileSync(modifiedPath, originalModifiedPathText) - fs.removeSync(newPath) if fs.existsSync(newPath) - it "returns status information for all new and modified files", -> fs.writeFileSync(modifiedPath, 'making this path modified') statusHandler = jasmine.createSpy('statusHandler') From 7514f704348d143a422e7291b60ef33c751394df Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:24:24 -0700 Subject: [PATCH 09/15] Set project path to temp working directory --- spec/git-spec.coffee | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 2f6de9032..46263c8ff 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -188,17 +188,13 @@ describe "Git", -> expect(repo.isStatusModified(repo.getCachedPathStatus(modifiedPath))).toBeTruthy() describe "buffer events", -> - [originalContent, editor] = [] + [editor] = [] beforeEach -> + atom.project.setPath(copyRepository()) + waitsForPromise -> - atom.workspace.open('sample.js').then (o) -> editor = o - - runs -> - originalContent = editor.getText() - - afterEach -> - fs.writeFileSync(editor.getPath(), originalContent) + atom.workspace.open('other.txt').then (o) -> editor = o it "emits a status-changed event when a buffer is saved", -> editor.insertNewline() @@ -232,15 +228,16 @@ describe "Git", -> expect(statusHandler.callCount).toBe 1 describe "when a project is deserialized", -> - [originalContent, buffer, project2] = [] + [buffer, project2] = [] afterEach -> - fs.writeFileSync(buffer.getPath(), originalContent) project2?.destroy() it "subscribes to all the serialized buffers in the project", -> + atom.project.setPath(copyRepository()) + waitsForPromise -> - atom.workspace.open('sample.js') + atom.workspace.open('file.txt') runs -> project2 = atom.project.testSerialization() From 81d9193bf44b08307ad9203146444b4c26ae1e93 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:32:00 -0700 Subject: [PATCH 10/15] Copy repository to temp folder --- spec/editor-view-spec.coffee | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/editor-view-spec.coffee b/spec/editor-view-spec.coffee index a6ef64cd4..990ca47a7 100644 --- a/spec/editor-view-spec.coffee +++ b/spec/editor-view-spec.coffee @@ -2413,20 +2413,21 @@ describe "EditorView", -> expect(editorView.getFirstVisibleScreenRow()).toBe(0) describe ".checkoutHead()", -> - [filePath, originalPathText] = [] + [filePath] = [] beforeEach -> - filePath = atom.project.resolve('git/working-dir/file.txt') - originalPathText = fs.readFileSync(filePath, 'utf8') + workingDirPath = temp.mkdirSync('atom-working-dir') + fs.copySync(path.join(__dirname, 'fixtures', 'git', 'working-dir'), workingDirPath) + fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git')) + atom.project.setPath(workingDirPath) + filePath = atom.project.resolve('file.txt') + waitsForPromise -> atom.workspace.open(filePath).then (o) -> editor = o runs -> editorView.edit(editor) - afterEach -> - fs.writeFileSync(filePath, originalPathText) - it "restores the contents of the editor view to the HEAD revision", -> editor.setText('') editor.save() @@ -2440,7 +2441,7 @@ describe "EditorView", -> fileChangeHandler.callCount > 0 runs -> - expect(editor.getText()).toBe(originalPathText) + expect(editor.getText()).toBe('undefined') describe ".pixelPositionForBufferPosition(position)", -> describe "when the editor view is detached", -> From bcad8c1b3e0bae02e1ea651ad3b6656370475a61 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:35:00 -0700 Subject: [PATCH 11/15] Remove # which is interpreted as a tag This spec was not running because of it since jasmine-tagged is configured to filter tags by process.platform --- spec/context-menu-manager-spec.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/context-menu-manager-spec.coffee b/spec/context-menu-manager-spec.coffee index 42c833bda..c136591eb 100644 --- a/spec/context-menu-manager-spec.coffee +++ b/spec/context-menu-manager-spec.coffee @@ -105,7 +105,7 @@ describe "ContextMenuManager", -> expect(menu[2].command).toEqual 'dev-command' expect(menu[3]).toBeUndefined() - describe "#executeBuildHandlers", -> + describe "executeBuildHandlers", -> menuTemplate = [ label: 'label' executeAtBuild: -> @@ -119,4 +119,3 @@ describe "ContextMenuManager", -> expect(buildFn).toHaveBeenCalled() expect(buildFn.mostRecentCall.args[0]).toBe event - From 1704c78eeade8eeab4f5263336ae2b5bcae9fdfe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:35:49 -0700 Subject: [PATCH 12/15] Enable core specs when run outside of clone repo The failing specs have been updated so that specs can now run without the requirement of a Git repository at the root. --- spec/spec-suite.coffee | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index 568c2132d..acec58aad 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -27,11 +27,6 @@ setSpecDirectory = (specDirectory) -> runAllSpecs = -> {resourcePath} = atom.getLoadSettings() - # Only run core specs when resource path is the Atom repository - if Git.exists(resourcePath) - requireSpecs(path.join(resourcePath, 'spec')) - setSpecType('core') - fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages') packagePaths = atom.packages.getAvailablePackageNames().map (packageName) -> atom.packages.resolvePackagePath(packageName) From 4c2931f6b5bc7d77c94c6bb9ff97c49d7152da5e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 15:40:49 -0700 Subject: [PATCH 13/15] Use forward slash on all platforms Paths are normalized by git-utils to use / on all platforms --- src/git.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git.coffee b/src/git.coffee index 7e9b22f4b..25c3db9fe 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -1,4 +1,4 @@ -{join, sep} = require 'path' +{join} = require 'path' _ = require 'underscore-plus' {Emitter, Subscriber} = require 'emissary' @@ -246,7 +246,7 @@ class Git # Returns a {Number} representing the status. This value can be passed to # {::isStatusModified} or {::isStatusNew} to get more information. getDirectoryStatus: (directoryPath) -> - directoryPath = "#{@relativize(directoryPath)}#{sep}" + directoryPath = "#{@relativize(directoryPath)}/" directoryStatus = 0 for path, status of @statuses directoryStatus |= status if path.indexOf(directoryPath) is 0 From bd873dc8517941c2d53067bf94d137bd3360218a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 30 May 2014 16:09:54 -0700 Subject: [PATCH 14/15] Upgrade to first-mate@1.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc8c30f95..8ed414332 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "coffeestack": "0.7.0", "delegato": "^1", "emissary": "^1.2.1", - "first-mate": "^1.6", + "first-mate": "^1.6.1", "fs-plus": "^2.2.3", "fstream": "0.1.24", "fuzzaldrin": "^1.1", From b6fcc35131515e06a6e406bef683debf3d53191a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 2 Jun 2014 10:12:38 -0700 Subject: [PATCH 15/15] Write removed file to temp directory --- spec/pane-view-spec.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/pane-view-spec.coffee b/spec/pane-view-spec.coffee index da3105f1a..8d3d3be27 100644 --- a/spec/pane-view-spec.coffee +++ b/spec/pane-view-spec.coffee @@ -166,7 +166,8 @@ describe "PaneView", -> it "removes the pane item", -> editor = null jasmine.unspy(window, 'setTimeout') - filePath = temp.openSync('atom').path + filePath = path.join(temp.mkdirSync(), 'file.txt') + fs.writeFileSync(filePath, '') waitsForPromise -> atom.workspace.open(filePath).then (o) -> editor = o