-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
304 additions
and
56 deletions.
There are no files selected for viewing
245 changes: 245 additions & 0 deletions
245
src/GitLabHealth-Model-Analysis-Tests/GitAnalyzerLocalTest.class.st
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,245 @@ | ||
Class { | ||
#name : #GitAnalyzerLocalTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'glphModel', | ||
'glphApi', | ||
'glhImporter', | ||
'projects', | ||
'gitAnalyzer', | ||
'fromCommit' | ||
], | ||
#category : #'GitLabHealth-Model-Analysis-Tests' | ||
} | ||
|
||
{ #category : #running } | ||
GitAnalyzerLocalTest >> setUp [ | ||
|
||
super setUp. | ||
|
||
glphModel := GLPHEModel new. | ||
gitAnalyzer := GitAnalyzer new onModel: glphModel. | ||
fromCommit := GLHCommit new. | ||
fromCommit short_id: 'testFromCommit'. | ||
fromCommit created_at: ('3 August 2021' asDate). | ||
glphModel add: fromCommit. | ||
|
||
gitAnalyzer fromCommit: fromCommit. | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsJavaComment [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ // hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 1 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsJavaContinueComment [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ * hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 1 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsJavaStopComment [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ */ hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 1 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsMixedMultipleComments [ | ||
|
||
| diffA diffARange addition additionB additionC | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ // hello world'. | ||
|
||
additionB := glphModel newDeletion. | ||
diffARange addChange: additionB. | ||
additionB sourceCode: '- // hello world'. | ||
|
||
additionC := glphModel newAddition. | ||
diffARange addChange: additionC. | ||
additionC sourceCode: '+ // hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 2 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsMultipleComments [ | ||
|
||
| diffA diffARange addition additionB additionC | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ // hello world'. | ||
|
||
additionB := glphModel newAddition. | ||
diffARange addChange: additionB. | ||
additionB sourceCode: '+ // hello world'. | ||
|
||
additionC := glphModel newAddition. | ||
diffARange addChange: additionC. | ||
additionC sourceCode: '+ // hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 3 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsPythonComment [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ */ hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 1 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentContributionsShouldBe0 [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newAddition. | ||
diffARange addChange: addition. | ||
addition sourceCode: '+ hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 0 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentInSomeAroundCode [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newLineOfCode. | ||
diffARange addChange: addition. | ||
addition sourceCode: '// hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 0 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testAnalyseCommentNotAnAddition [ | ||
|
||
| diffA diffARange addition | | ||
diffA := GLHDiff new. | ||
diffA new_path: 'new/test/path.txt'. | ||
fromCommit addDiff: diffA. | ||
glphModel add: diffA. | ||
"Set DiffA ranges" | ||
diffARange := glphModel newDiffRange. | ||
diffA diffRanges: { diffARange }. | ||
|
||
addition := glphModel newDeletion. | ||
diffARange addChange: addition. | ||
addition sourceCode: '- // hello world'. | ||
|
||
self assert: gitAnalyzer analyseCommentContributions equals: 0 | ||
] | ||
|
||
{ #category : #test } | ||
GitAnalyzerLocalTest >> testArrangeCommitsByDate [ | ||
|
||
| commitA2 commitA3 commitB result | | ||
commitA2 := GLHCommit new. | ||
commitA2 short_id: 'testFromCommit2'. | ||
commitA2 created_at: ('3 August 2021' asDate). | ||
glphModel add: commitA2. | ||
|
||
commitA3 := GLHCommit new. | ||
commitA3 short_id: 'testFromCommit3'. | ||
commitA3 created_at: ('3 August 2021' asDate). | ||
glphModel add: commitA3. | ||
|
||
commitB := GLHCommit new. | ||
commitB short_id: 'testFromCommitB'. | ||
commitB created_at: ('4 August 2021' asDate). | ||
glphModel add: commitB. | ||
|
||
result := gitAnalyzer arrangeCommitsByDate: { | ||
fromCommit. | ||
commitA2. | ||
commitA3. | ||
commitB }. | ||
|
||
self assert: result size equals: 2. | ||
self assert: (result at: '3 August 2021') size equals: 3. | ||
self assert: (result at: '4 August 2021') size equals: 1. | ||
] |
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
Oops, something went wrong.