-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracts Tonel support for coverage from SCIPharoCodeCoverage to SCIS…
…queakTonelCodeCoverage and use it by default.
- Loading branch information
1 parent
25221dd
commit 073df0d
Showing
18 changed files
with
149 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
14 changes: 14 additions & 0 deletions
14
...ueak-Core.package/SCISqueakTonelCodeCoverage.class/class/isInTonelFormatCodeLocatedAt..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,14 @@ | ||
as yet unclassified | ||
isInTonelFormatCodeLocatedAt: aDirectoryName | ||
|
||
| dir prop | | ||
"1) First, look for a .properties file, assume STON format, and look for #format: #tonel." | ||
(prop := (dir := FileDirectory on: aDirectoryName) / '.properties') exists ifTrue: [ | ||
prop readStreamDo: [ :stream | (STON fromStream: stream) at: #format ifPresent: [ :value | ^ value = #tonel ] ] ]. | ||
|
||
"2) Scan for a package directory with at least one having package.st." | ||
dir entries do: [:projectEntry | | ||
projectEntry isDirectory "= package" ifTrue: [ | ||
(projectEntry asFileDirectory / 'package.st') exists ifTrue: [^ true] ]]. | ||
|
||
^ false |
8 changes: 8 additions & 0 deletions
8
...talkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/class/tonelFilePathFor.in..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,8 @@ | ||
as yet unclassified | ||
tonelFilePathFor: class in: aDirectoryName | ||
| packageName packagePath | | ||
packageName := self packageNameForClass: class. | ||
packagePath := aDirectoryName , SmalltalkCI pathNameDelimiter , packageName. | ||
^ (SmalltalkCI fileExists: packagePath) | ||
ifTrue: [ packagePath , SmalltalkCI pathNameDelimiter , (self theNonMetaClassOf: class) name , '.class.st' ] | ||
ifFalse: [ "This can be an extension. Currently not supported" SCIError signal: 'Extensions are unsupported in coverage' ] |
4 changes: 4 additions & 0 deletions
4
...talkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/allClassesToCover.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,4 @@ | ||
accessing | ||
allClassesToCover | ||
|
||
^ allClassesToCover ifNil: [ allClassesToCover := super allClassesToCover asArray ] |
6 changes: 6 additions & 0 deletions
6
...-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/coverallsSourceFilesIn..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,6 @@ | ||
coveralls | ||
coverallsSourceFilesIn: projectDirectory | ||
|
||
^ (self isInTonelFormat: projectDirectory) | ||
ifTrue: [ self tonelCoverallsSourceFilesIn: projectDirectory ] | ||
ifFalse: [ super coverallsSourceFilesIn: projectDirectory ] |
5 changes: 5 additions & 0 deletions
5
...ory/SmalltalkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/finishUp.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,5 @@ | ||
setup | ||
finishUp | ||
|
||
super finishUp. | ||
coveredMethodsByClassName := coveredMethods groupBy: [ :method | method actualClass name ] |
5 changes: 5 additions & 0 deletions
5
...ltalkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/isInTonelFormat..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,5 @@ | ||
private | ||
isInTonelFormat: projectDirectory | ||
|
||
^ spec loading anySatisfy: [ :loadspec | | ||
self class isInTonelFormatCodeLocatedAt: projectDirectory, SmalltalkCI pathNameDelimiter, loadspec directory ] |
5 changes: 5 additions & 0 deletions
5
...tory/SmalltalkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/startUp.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,5 @@ | ||
setup | ||
startUp | ||
|
||
super startUp. | ||
includedMethodsByClassName := includedMethods groupBy: [ :method | method actualClass name ]. |
19 changes: 19 additions & 0 deletions
19
...kCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/tonelCoverageFor.in..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,19 @@ | ||
private | ||
tonelCoverageFor: classToCover in: filePath | ||
"The rationale of this method is to process the file line by line. | ||
When a method start is found, get the coverage status of this method and apply it to the following lines until the method end. | ||
When a method end is found reset the coverage status as excluded" | ||
|
||
| coverageByLine coverageStatus inComment | | ||
coverageByLine := OrderedCollection new. | ||
coverageStatus := nil. "For coveralls nil represents an excluded line" | ||
inComment := false. | ||
(FileStream readOnlyFileNamed: filePath do: [ :stream | stream contents ]) | ||
linesDo: [ :line | | ||
(line beginsWith: $" asString ) ifTrue: [ inComment := inComment not ]. | ||
(inComment not and: [line beginsWith: classToCover name]) | ||
ifTrue: [ "Start of method" coverageStatus := self tonelMethodCoverageStatusFor: line ]. | ||
coverageByLine add: coverageStatus. | ||
(inComment not and: [line beginsWith: ']']) | ||
ifTrue: [ "End Of Method" coverageStatus := nil ] ]. | ||
^ coverageByLine asArray |
11 changes: 11 additions & 0 deletions
11
...Core.package/SCISqueakTonelCodeCoverage.class/instance/tonelCoverallsSourceFileFor.in..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,11 @@ | ||
private | ||
tonelCoverallsSourceFileFor: classToCover in: projectDirectory | ||
|
||
| sourceDirectory filePath | | ||
sourceDirectory := self tonelSourceDirectoryFor: projectDirectory. | ||
filePath := self class tonelFilePathFor: classToCover in: sourceDirectory. | ||
^ Dictionary | ||
newFrom: | ||
{('name' -> (self class relativeUnixPathOf: filePath to: projectDirectory)). | ||
('source_digest' -> (self class md5Of: filePath)). | ||
('coverage' -> (self tonelCoverageFor: classToCover in: filePath))} |
12 changes: 12 additions & 0 deletions
12
...ak-Core.package/SCISqueakTonelCodeCoverage.class/instance/tonelCoverallsSourceFilesIn..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,12 @@ | ||
coveralls | ||
tonelCoverallsSourceFilesIn: projectDirectory | ||
|
||
| sourceFilesCoverage | | ||
sourceFilesCoverage := OrderedCollection new. | ||
self allClassesToCover | ||
select: [ :class | class isMeta not ] | ||
thenDo: [ :classToCover | | ||
[ sourceFilesCoverage add: (self tonelCoverallsSourceFileFor: classToCover in: projectDirectory) ] | ||
on: SCIError | ||
do: [ :signal | signal return ] ]. | ||
^ sourceFilesCoverage asArray |
19 changes: 19 additions & 0 deletions
19
...k-Core.package/SCISqueakTonelCodeCoverage.class/instance/tonelMethodCoverageStatusFor..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,19 @@ | ||
private | ||
tonelMethodCoverageStatusFor: methodDeclarationLine | ||
|
||
"See http://docs.coveralls.io/api-reference for value mapping." | ||
|
||
| selector methodDeclarationParts actualClassName | | ||
|
||
methodDeclarationParts := methodDeclarationLine findTokens: '>>'. | ||
actualClassName := methodDeclarationParts first withBlanksTrimmed. | ||
selector := (Smalltalk globals at: #TonelParser) new extractSelector: (methodDeclarationParts last copyWithout: $]). | ||
|
||
"Coveralls: | ||
If the method is excluded -> nil | ||
If the method is included and covered -> 1 | ||
If the method is inlcuded and uncovered -> 0" | ||
^ (includedMethodsByClassName at: actualClassName ifAbsent: [ #() ]) | ||
detect: [ :methodReference | methodReference selector = selector ] | ||
ifFound: [ :methodReference | (coveredMethodsByClassName at: actualClassName ifAbsent: [ #() ]) detect: [ :coveredMethod | coveredMethod = methodReference ] ifFound: [ 1 ] ifNone: [ 0 ] ] | ||
ifNone: [ nil ] |
7 changes: 7 additions & 0 deletions
7
...Squeak-Core.package/SCISqueakTonelCodeCoverage.class/instance/tonelSourceDirectoryFor..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,7 @@ | ||
private | ||
tonelSourceDirectoryFor: projectDirectory | ||
^ spec loading | ||
detect: | ||
[ :loadspec | SmalltalkCI fileExists: projectDirectory , SmalltalkCI pathNameDelimiter , loadspec directory ] | ||
ifFound: [ :loadspec | projectDirectory , SmalltalkCI pathNameDelimiter , loadspec directory ] | ||
ifNone: [ NotFound signal ] |
15 changes: 15 additions & 0 deletions
15
...ry/SmalltalkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/methodProperties.json
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,15 @@ | ||
{ | ||
"class" : { | ||
"isInTonelFormatCodeLocatedAt:" : "mt 6/12/2024 18:12", | ||
"tonelFilePathFor:in:" : "mt 6/12/2024 17:34" }, | ||
"instance" : { | ||
"allClassesToCover" : "mt 6/12/2024 17:38", | ||
"coverallsSourceFilesIn:" : "mt 6/12/2024 17:37", | ||
"finishUp" : "mt 6/12/2024 17:42", | ||
"isInTonelFormat:" : "mt 6/12/2024 17:35", | ||
"startUp" : "mt 6/12/2024 17:41", | ||
"tonelCoverageFor:in:" : "mt 6/12/2024 18:19", | ||
"tonelCoverallsSourceFileFor:in:" : "mt 6/12/2024 17:43", | ||
"tonelCoverallsSourceFilesIn:" : "mt 6/12/2024 17:39", | ||
"tonelMethodCoverageStatusFor:" : "mt 6/12/2024 18:17", | ||
"tonelSourceDirectoryFor:" : "mt 6/12/2024 17:43" } } |
16 changes: 16 additions & 0 deletions
16
repository/SmalltalkCI-Squeak-Core.package/SCISqueakTonelCodeCoverage.class/properties.json
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,16 @@ | ||
{ | ||
"category" : "SmalltalkCI-Squeak-Core", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "", | ||
"instvars" : [ | ||
"allClassesToCover", | ||
"includedMethodsByClassName", | ||
"coveredMethodsByClassName" ], | ||
"name" : "SCISqueakTonelCodeCoverage", | ||
"pools" : [ | ||
], | ||
"super" : "SCISqueakCodeCoverage", | ||
"type" : "normal" } |
2 changes: 1 addition & 1 deletion
2
...sitory/SmalltalkCI-Squeak-Core.package/SmalltalkCISqueak.class/class/codeCoverageClass.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
compatibility | ||
codeCoverageClass | ||
^ SCISqueakCodeCoverage | ||
^ SCISqueakTonelCodeCoverage |
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
2 changes: 1 addition & 1 deletion
2
repository/SmalltalkCI-Squeak-Core.package/monticello.meta/version
Large diffs are not rendered by default.
Oops, something went wrong.