Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI not working #118

Merged
merged 17 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/MuTalk-CI-Tests/MTCIMarkdownExporterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Class {
#name : 'MTCIMarkdownExporterTest',
#superclass : 'TestCase',
#category : 'MuTalk-CI-Tests',
#package : 'MuTalk-CI-Tests'
}

{ #category : 'as yet unclassified' }
MTCIMarkdownExporterTest >> testMarkdownExporter [

| analysis md moreInfo |
analysis := MTAnalysis new
testClasses: { MTSmallBankTest };
classesToMutate: { MTSmallBank }.
analysis run.
analysis generalResult.
moreInfo := MTCoveragePropagationPreparation new
mtResult: analysis;
prepare.

md := MTCIMarkdownExporter new
mtResult: analysis;
cloneLocation:
FileLocator localDirectory fullName
, '/iceberg/pharo-contributions/mutalk';
root: 'src';
export.

self assert: md isString.
self assert: md isNotEmpty.
]
15 changes: 8 additions & 7 deletions src/MuTalk-CI-Tests/MTCITonelJsonExporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ Class {

{ #category : 'tests' }
MTCITonelJsonExporterTest >> testWorking [
"requires https://github.com/mabdi/smalltalk-SmallBank"

| analysis json moreInfo |
| analysis json moreInfo repo |
guillep marked this conversation as resolved.
Show resolved Hide resolved
self skip.

analysis := MTAnalysis new
testClasses: { SmallBankTest };
classesToMutate: { SmallBank }.
testClasses: { MTSmallBankTest };
classesToMutate: { MTSmallBank }.
analysis run.
moreInfo := MTCoveragePropagationPreparation new
mtResult: analysis;
prepare.
repo := IceRepository repositories detect: [ :aRepo |
aRepo workingCopy packages anySatisfy: [ :package |
package name = MTSmallBank package name ] ].

json := MTCITonelJsonExporter new
mtResult: analysis;
coverageInfo: moreInfo;
cloneLocation: FileLocator localDirectory fullName
, '/iceberg/mabdi/smalltalk-smallbank';
cloneLocation: repo location fullName;
root: 'src';
export.
self assert: json class equals: '' class
Expand Down
40 changes: 40 additions & 0 deletions src/MuTalk-CI-Tests/MTSmallBank.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class {
#name : 'MTSmallBank',
#superclass : 'Object',
#instVars : [
'balance'
],
#category : 'MuTalk-CI-Tests',
#package : 'MuTalk-CI-Tests'
}

{ #category : 'accessing' }
MTSmallBank >> balance [
^ balance
]

{ #category : 'accessing' }
MTSmallBank >> deposit: amount [
balance := balance + amount
]

{ #category : 'initialization' }
MTSmallBank >> initialize [
balance := 0
]

{ #category : 'accessing' }
MTSmallBank >> rand [
" Flaky detection "
^ (1 to: 1000) atRandom

]

{ #category : 'accessing' }
MTSmallBank >> withdraw: amount [
balance >= amount
ifTrue: [
balance := balance - amount.
^ true ].
^ false
]
60 changes: 60 additions & 0 deletions src/MuTalk-CI-Tests/MTSmallBank2.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Class {
#name : 'MTSmallBank2',
#superclass : 'Object',
#instVars : [
'balance'
],
#category : 'MuTalk-CI-Tests',
#package : 'MuTalk-CI-Tests'
}

{ #category : 'as yet unclassified' }
MTSmallBank2 class >> calculateRate: aPercent amount: anInt [
" I expect it profiled"
aPercent < 0 ifTrue: [ self error: 'negetive ' ].
^ (anInt * aPercent / 100) asInteger
]

{ #category : 'as yet unclassified' }
MTSmallBank2 class >> calculateRate: aPercent amount: anInt month: monthes [
"I expect it not profiled."
^ (self calculateRate: aPercent amount: anInt) / monthes asInteger
]

{ #category : 'as yet unclassified' }
MTSmallBank2 class >> calculateRateExample [
"I expect it added in input amplification"

^ self calculateRate: 2 amount: 1000000 month: 12
]

{ #category : 'instance creation' }
MTSmallBank2 class >> with: amount [
^ self new
deposit: amount;
yourself
]

{ #category : 'accessing' }
MTSmallBank2 >> balance [
^ balance
]

{ #category : 'accessing' }
MTSmallBank2 >> deposit: amount [
amount < 0
ifTrue: [ Error new signal ].
balance := balance + amount
]

{ #category : 'initialization' }
MTSmallBank2 >> initialize [
balance := 0
]

{ #category : 'accessing' }
MTSmallBank2 >> withdraw: amount [
balance >= amount
ifTrue: [ balance := balance - amount ]
ifFalse: [ Error new signal ]
]
37 changes: 37 additions & 0 deletions src/MuTalk-CI-Tests/MTSmallBank2Test.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Class {
#name : 'MTSmallBank2Test',
#superclass : 'TestCase',
#category : 'MuTalk-CI-Tests',
#package : 'MuTalk-CI-Tests'
}

{ #category : 'tests' }
MTSmallBank2Test >> testDeposit [
| b |
b := MTSmallBank2 with: 10.
self assert: b balance equals: 10.
b deposit: 100.
self assert: b balance equals: 110
]

{ #category : 'tests' }
MTSmallBank2Test >> testInit [
| b |
b := MTSmallBank2 new.
self assert: b balance equals: 0
]

{ #category : 'tests' }
MTSmallBank2Test >> testPercent [
MTSmallBank2 calculateRate: 10 amount: 1000
]

{ #category : 'tests' }
MTSmallBank2Test >> testWithdraw [
| b |
b := MTSmallBank2 new.
b deposit: 100.
self assert: b balance equals: 100.
b withdraw: 30.
self assert: b balance equals: 70
]
32 changes: 32 additions & 0 deletions src/MuTalk-CI-Tests/MTSmallBankTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class {
#name : 'MTSmallBankTest',
#superclass : 'TestCase',
#category : 'MuTalk-CI-Tests',
#package : 'MuTalk-CI-Tests'
}

{ #category : 'tests' }
MTSmallBankTest >> testDeposit [
| b |
b := MTSmallBank new.
b deposit: 10.
self assert: b balance equals: 10.
b deposit: 100.
self assert: b balance equals: 110
]

{ #category : 'tests' }
MTSmallBankTest >> testInit [
| b |
b := MTSmallBank new .self assert: b balance equals: 0
]

{ #category : 'tests' }
MTSmallBankTest >> testWithdraw [
| b |
b := MTSmallBank new.
b deposit: 100.
self assert: b balance equals: 100.
b withdraw: 30.
self assert: b balance equals: 70
]
79 changes: 79 additions & 0 deletions src/MuTalk-CI/MTAbstractExporter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Class {
#name : 'MTAbstractExporter',
#superclass : 'Object',
#instVars : [
'mtResult',
'pull_request_id',
'commit',
'cloneLocation',
'root'
],
#category : 'MuTalk-CI',
#package : 'MuTalk-CI'
}

{ #category : 'accessing' }
MTAbstractExporter >> cloneLocation [

^ cloneLocation
]

{ #category : 'accessing' }
MTAbstractExporter >> cloneLocation: anObject [

cloneLocation := anObject
]

{ #category : 'accessing' }
MTAbstractExporter >> commit [

^ commit
]

{ #category : 'accessing' }
MTAbstractExporter >> commit: anObject [

commit := anObject
]

{ #category : 'as yet unclassified' }
MTAbstractExporter >> export [

self subclassResponsibility
]

{ #category : 'accessing' }
MTAbstractExporter >> mtResult [

^ mtResult
]

{ #category : 'accessing' }
MTAbstractExporter >> mtResult: anObject [

mtResult := anObject
]

{ #category : 'accessing' }
MTAbstractExporter >> pull_request_id [

^ pull_request_id
]

{ #category : 'accessing' }
MTAbstractExporter >> pull_request_id: anObject [

pull_request_id := anObject
]

{ #category : 'accessing' }
MTAbstractExporter >> root [

^ root
]

{ #category : 'accessing' }
MTAbstractExporter >> root: anObject [

root := anObject
]
27 changes: 0 additions & 27 deletions src/MuTalk-CI/MTAbstractJsonExporter.class.st

This file was deleted.

31 changes: 30 additions & 1 deletion src/MuTalk-CI/MTCI.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ MTCI >> exportFileName [
^ '__mutalk_export.json'
]

{ #category : 'private' }
MTCI >> exportMarkdownFileName [
^ '__mutalk_summary.md'
]

{ #category : 'private' }
MTCI >> exportResultJson: analysis [

Expand Down Expand Up @@ -103,6 +108,29 @@ MTCI >> exportResultJson: analysis coverageInfo: coverageInfo [
close
]

{ #category : 'private' }
MTCI >> exportSummaryMarkdown: analysis [

| markdown file repo commitFrom commitTo timestamp |
repo := self getRepo.
commitFrom := commit.
commitTo := repo head commit id.
timestamp := DateAndTime now asUnixTime.

markdown := MTCIMarkdownExporter new
mtResult: analysis;
commit: commitTo;
root: repo subdirectory;
cloneLocation: repo location fullName;
export.

file := FileLocator imageDirectory / self exportMarkdownFileName.
file exists ifTrue: [ file delete ].
file writeStream
nextPutAll: markdown;
close
]

{ #category : 'as yet unclassified' }
MTCI >> getRepo [

Expand Down Expand Up @@ -205,5 +233,6 @@ MTCI >> runMutalkTargets: targets tests: tests generationStrategy: generationStr
mutantGenerationStrategy: generationStrategy.
analysis run.
coverageInfo := self prepareCoverageInfo: analysis.
self exportResultJson: analysis coverageInfo: coverageInfo
self exportResultJson: analysis coverageInfo: coverageInfo.
self exportSummaryMarkdown: analysis
]
Loading
Loading