Skip to content

Commit

Permalink
Add tests for pharo-vcs#880
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Jun 26, 2018
1 parent caade18 commit c08f13d
Show file tree
Hide file tree
Showing 40 changed files with 138 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
accessing
iceVersion: anObject
| repository packageDirectoryName directoryName |
| repository packageDirectoryName |
iceVersion := anObject.
repository := iceVersion commit repository.
package := iceVersion package.

packageDirectoryName := iceVersion commit writerClass directoryNameFor: package.
directoryName := repository subdirectory isEmptyOrNil
ifTrue: [ packageDirectoryName ]
ifFalse: [ repository subdirectory, '/', packageDirectoryName ].

self packageDirectory: directoryName
self packageDirectory: (repository subdirectoryPath / packageDirectoryName) pathString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API-accessing
subdirectoryPath

^ RelativePath with: self subdirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API-accessing
subdirectoryReference

^ self location resolve: self subdirectoryPath
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
initialization
newRepositoryNamed: projectName

self subclassResponsibility
^ self newRepositoryNamed: projectName withSubdirectory: ''
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
newRepositoryNamed: projectName withSubdirectory: aSubdirectory

self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
initialize
super initialize.
subdirectory := ''.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ running
setUp

super setUp.
repository := factory newRepositoryNamed: projectName
repository := factory newRepositoryNamed: projectName withSubdirectory: self subdirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
running
subdirectory: aSubdirectory

subdirectory := aSubdirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
running
subdirectory

^ subdirectory
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"repository"
"repository",
"subdirectory"
],
"name" : "IceBasicRepositoryFixture",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
initialization
newRepositoryNamed: projectName
newRepositoryNamed: projectName withSubdirectory: aSubdirectory

| repository |
(self location / projectName) ensureDeleteAll.
repository := IceRepositoryCreator new
location: self location / projectName;
subdirectory: aSubdirectory;
createNewRepositoryNamed: projectName.

(OSEnvironment default at: 'CI' ifAbsent: []) = 'true' ifTrue: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
initialization
newRepositoryNamed: projectName

newRepositoryNamed: projectName withSubdirectory: aSubdirectory
"Ignore the subdirectory in memory"
| repository |
repository := IceMemoryRepository new.
repository workingCopy: (IceRingWorkingCopy fromWorkingCopy: repository workingCopy).
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
running
newFixture

^ IceSinglePackageFixture inGit
subdirectory: '.';
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
running
testCodeSubdirectoryIsRoot

self assert: self repository location equals: self repository subdirectoryReference
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "IceSinglePackageLocalRepositoryTest",
"category" : "Iceberg-Tests-Git",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "IceSinglePackageLocalGitRepositoryWithDotSubdirectoryTest",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
running
newFixture

^ IceSinglePackageFixture inGit
subdirectory: 'src';
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "IceSinglePackageLocalRepositoryTest",
"category" : "Iceberg-Tests-Git",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "IceSinglePackageLocalGitRepositoryWithSubdirectoryTest",
"type" : "normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ testChangeClassSideMakesChangesContainClassDefinition
with: [ :class | class metaclass instanceVariables: #(someClassInstVar) ].

diff := self repository workingCopyDiff.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ testChangeClassSideMakesIsExportedInCommit

diff := self repository headCommit diffToParent.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ testChangeClassSideMakesIsExportedInCommitSecondVariable
self repository commitWithMessage: 'Added another class instance variable'.

diff := self repository headCommit diffToParent.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value isModification.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value isModification.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ testChangeClassWithTraitsSideMakesIsExportedInCommit
self repository commitWithMessage: 'Added class instance variable'.

diff := self repository headCommit diffToParent.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ testChangeClassWithTraitsSideMakesIsExportedInCommitSecondVariable
self repository commitWithMessage: 'Added another class instance variable'.

diff := self repository headCommit diffToParent.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value isModification.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value isModification.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting class') value definition name equals: #'IceGeneratedClassForTesting class'.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ testCreateClassInImageMakesChangesContainClassDefinition
inPackage: self packageName1 asSymbol.

diff := self repository workingCopyDiff.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting') value isAddition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting') value definition isClassDefinition.
self assert: (diff tree / self packageName1 / 'IceGeneratedClassForTesting') value definition name equals: #IceGeneratedClassForTesting.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting') value definition isClassDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'IceGeneratedClassForTesting') value definition name equals: #IceGeneratedClassForTesting.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ testCreateExtensionMethodMakesExtensionMethodAsAddition
inPackage: self packageName1 asSymbol.

diff := self repository workingCopyDiff.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'ToBeExtended') value isAddition.
self assert: (diff tree / self packageName1 / 'ToBeExtended') value definition isExtensionDefinition.
self assert: (diff tree / self packageName1 / 'ToBeExtended' / 'method') value isAddition.
self assert: (diff tree / self packageName1 / 'ToBeExtended' / 'method') value definition isMethodDefinition.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended') value definition isExtensionDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended' / 'method') value isAddition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended' / 'method') value definition isMethodDefinition.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ testRemoveExtensionMethodMakesExtensionRemoval
fromPackage: self packageName1 asSymbol.

diff := self repository workingCopyDiff.
self assert: diff tree children size equals: 1.
self assert: (diff tree / self packageName1) children size equals: 1.
self assert: (diff tree / self packageName1 / 'ToBeExtended') value isRemoval.
self assert: (diff tree / self packageName1 / 'ToBeExtended') value definition isExtensionDefinition.
self assert: (diff tree / self packageName1 / 'ToBeExtended' / 'method') value isRemoval.
self assert: (diff tree / self packageName1 / 'ToBeExtended' / 'method') value definition isMethodDefinition.
self assert: diff codeSubdirectoryNode children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1) children size equals: 1.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended') value isRemoval.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended') value definition isExtensionDefinition.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended' / 'method') value isRemoval.
self assert: (diff codeSubdirectoryNode / self packageName1 / 'ToBeExtended' / 'method') value definition isMethodDefinition.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ testRemovePackageRemovesIt
package := self repository workingCopy packageNamed: self packageName1.
package remove.

self assert: (self repository workingCopyDiff tree / self packageName1) value isRemoval
self assert: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1) value isRemoval
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ testRevertSingleDefinitionRevertsClassAddition
inPackage: self packageName1 asSymbol.

self assertClassExists: className.
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className).
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className).
self denyClassExists: className.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ testRevertSingleDefinitionRevertsClassRemoval
removeClassNamed: className.

self denyClassExists: className.
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className).
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className).
self assertClassExists: className.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ testRevertSingleDefinitionRevertsClassSlotModification

self assert: ((self repository workingCopy
environment ask behaviorNamed: className) instVarNames includes: #slot).
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className).
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className).
self deny: ((self repository workingCopy
environment ask behaviorNamed: className) instVarNames includes: #slot).
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ testRevertSingleDefinitionRevertsMethodAddition
createMethod: 'method' inClass: className.

self assertMethodExists: 'method' inClass: className.
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className / 'method').
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className / 'method').
self denyMethodExists: 'method' inClass: className.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testRevertSingleDefinitionRevertsMethodModification
self
assert: ((self repository workingCopy environment ask behaviorNamed: className) methodNamed: 'method') sourceCode
equals: 'method ^ 42'.
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className / 'method').
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className / 'method').
self assertMethodExists: 'method' inClass: className.
self
assert: ((self repository workingCopy environment ask behaviorNamed: className) methodNamed: 'method') sourceCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ testRevertSingleDefinitionRevertsMethodRemoval
removeMethod: 'method' fromClass: className.

self denyMethodExists: 'method' inClass: className.
self workingCopy discardChanges: (self repository workingCopyDiff tree / self packageName1 / className / 'method').
self workingCopy discardChanges: (self repository workingCopyDiff codeSubdirectoryNode / self packageName1 / className / 'method').
self assertMethodExists: 'method' inClass: className.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
private
ensureSourceCodeDirectoryIn: aNode
| codeSubdirectoryName |

codeSubdirectoryName := diff repository subdirectory.
codeSubdirectoryName ifEmpty: [ ^ aNode ].
(codeSubdirectoryName isEmpty or: [ codeSubdirectoryName = '.' ])
ifTrue: [ ^ aNode ].

aNode childAt: codeSubdirectoryName ifPresent: [ :node |
self assert: node value isDirectoryDefinition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ isCodeSubdirectory: aNode

| nodeLocation repositorySubdirectoryLocation |
nodeLocation := self repository location resolve: aNode path.
repositorySubdirectoryLocation := self repository location resolve: (Path from: self repository subdirectory).
repositorySubdirectoryLocation := self repository subdirectoryReference.
^ nodeLocation = repositorySubdirectoryLocation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enumerating
firstNodeSuchThat: conditionBlock

^ self firstNodeSuchThat: conditionBlock ifNone: [ NotFound signalFor: conditionBlock ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enumerating
firstNodeSuchThat: conditionBlock ifNone: noneBlock

(conditionBlock value: self)
ifTrue: [ ^ self ].

^ noneBlock value
4 changes: 4 additions & 0 deletions Iceberg.package/IceEmptyNode.class/instance/path.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
path

^ RelativePath new

This file was deleted.

0 comments on commit c08f13d

Please sign in to comment.