From 49540d316947cabcec4e8563c7d870947d1f64bb Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 13:58:56 +0200 Subject: [PATCH 1/6] test --- .../BaselineOfExecutableRequirements.class.st | 5 +- .../ExReqToploLoginRequirements.class.st | 11 +- .../ExReqToploLoginSimulation.class.st | 2 +- .../ExReqToploLoginWidget.class.st | 10 +- .../ExReqRepositoryReport.class.st | 69 ++----- .../ExReqStepReport.class.st | 41 +++++ .../ExReqTracingPoint.class.st | 2 +- .../NeoExReqInstrumentationBuilder.class.st | 173 ++++++++++++++++++ .../NeoExReqMethodProxyHandler.class.st | 9 + ...eqPostconditionMethodProxyHandler.class.st | 15 ++ ...NeoExReqPostconditionTracingPoint.class.st | 23 +++ ...ReqPreconditionMethodProxyHandler.class.st | 15 ++ .../NeoExReqPreconditionTracingPoint.class.st | 15 ++ .../NeoExReqTracingPoint.class.st | 75 ++++++++ .../TExReqPostconditionsHandler.trait.st | 15 ++ .../TExReqPreconditionsHandler.trait.st | 15 ++ .../TExReqTracingHandler.trait.st | 27 +++ 17 files changed, 457 insertions(+), 65 deletions(-) create mode 100644 src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st create mode 100644 src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st create mode 100644 src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st create mode 100644 src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st create mode 100644 src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st create mode 100644 src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st create mode 100644 src/ExecutableRequirements/NeoExReqTracingPoint.class.st create mode 100644 src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st create mode 100644 src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st create mode 100644 src/ExecutableRequirements/TExReqTracingHandler.trait.st diff --git a/src/BaselineOfExecutableRequirements/BaselineOfExecutableRequirements.class.st b/src/BaselineOfExecutableRequirements/BaselineOfExecutableRequirements.class.st index 301985f..3cab051 100644 --- a/src/BaselineOfExecutableRequirements/BaselineOfExecutableRequirements.class.st +++ b/src/BaselineOfExecutableRequirements/BaselineOfExecutableRequirements.class.st @@ -29,8 +29,11 @@ BaselineOfExecutableRequirements >> baselineForCommon: spec [ { #category : 'baselines' } BaselineOfExecutableRequirements >> coreDependencies: spec [ - "No dependencies" + spec + baseline: 'MethodProxies' + with: [ spec repository: 'github://Nyan11/MethodProxies/src' ] + ] { #category : 'baselines' } diff --git a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginRequirements.class.st b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginRequirements.class.st index 0b21704..8b45b39 100644 --- a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginRequirements.class.st +++ b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginRequirements.class.st @@ -1006,9 +1006,14 @@ ExReqToploLoginRequirements >> capella_requirement_3 [ (ExReqToploLoginSimulation >> #authenticateUsername:password:) ast withPrecondition: [ :obj :args | - (obj - perform: #authenticateUsername:password: - withArguments: args) not ]. + [ + obj + perform: #authenticateUsername:password: + withArguments: args. + false ] + on: Exception + do: [ true ] ] + withPostcondition: [ true ]. verif addStepOnAST: (ExReqToploLoginWidget >> #loginAction) ast withPostcondition: [ :obj :args | diff --git a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginSimulation.class.st b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginSimulation.class.st index 9d97f5a..31ae7eb 100644 --- a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginSimulation.class.st +++ b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginSimulation.class.st @@ -57,7 +57,7 @@ ExReqToploLoginSimulation >> authenticateUsername: aUsernameString password: aPa self database at: aUsernameString ifPresent: [ :value | ^ aPasswordString = value ] - ifAbsent: [ ^ false ] + ifAbsent: [ Exception signal: 'Wrong credentials' ] ] { #category : 'as yet unclassified' } diff --git a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginWidget.class.st b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginWidget.class.st index 2cf22f3..0b5516f 100644 --- a/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginWidget.class.st +++ b/src/ExecutableRequirements-Toplo-Example/ExReqToploLoginWidget.class.st @@ -367,11 +367,11 @@ ExReqToploLoginWidget >> initialize [ { #category : 'as yet unclassified' } ExReqToploLoginWidget >> loginAction [ - (self authenticationBlock - value: self usernameValue - value: self passwordValue) - ifTrue: [ self loginBlock value ] - ifFalse: [ + [ self authenticationBlock + value: self usernameValue + value: self passwordValue. + self loginBlock value ] + on: Exception do: [ :error | self loginStatusContainer visibility: BlVisibility visible. self passwordInput text: '' ] ] diff --git a/src/ExecutableRequirements/ExReqRepositoryReport.class.st b/src/ExecutableRequirements/ExReqRepositoryReport.class.st index 4a4f330..29796d8 100644 --- a/src/ExecutableRequirements/ExReqRepositoryReport.class.st +++ b/src/ExecutableRequirements/ExReqRepositoryReport.class.st @@ -4,8 +4,8 @@ Class { #instVars : [ 'requirementReports', 'repository', - 'tracingPoints', - 'announcer' + 'announcer', + 'builder' ], #category : 'ExecutableRequirements-Model-Report', #package : 'ExecutableRequirements', @@ -73,6 +73,12 @@ ExReqRepositoryReport >> associatedPackages [ ^ self repository associatedPackages. ] +{ #category : 'as yet unclassified' } +ExReqRepositoryReport >> builder [ + + ^ builder +] + { #category : 'as yet unclassified' } ExReqRepositoryReport >> closeReport [ @@ -81,40 +87,6 @@ ExReqRepositoryReport >> closeReport [ requirementReports := { } ] -{ #category : 'as yet unclassified' } -ExReqRepositoryReport >> createTracingPoints [ - - | stepReports preconditionNodeDictionary postconditionNodeDictionary| - " - - Step1: Get all step reports. - - Step2: Create a dictionary with all ast -> step reports. - - Step3: Create all PreconditionTracingPoint. - - Step4: Create a dictionary with all ast & ast methodNode -> step reports. - - Step5: Create all PostconditionTracingPoint. - " - stepReports := self requirementReports flatCollect: [ :req | - req verificationReports flatCollect: #stepReports ]. - preconditionNodeDictionary := Dictionary new. - postconditionNodeDictionary := Dictionary new. - stepReports do: [ :stepReport | - preconditionNodeDictionary - at: stepReport step node - ifPresent: [ :col | col add: stepReport ] - ifAbsentPut: [ OrderedCollection with: stepReport ]. - postconditionNodeDictionary - at: stepReport step node - ifPresent: [ :col | col add: stepReport ] - ifAbsentPut: [ Set with: stepReport ]. - postconditionNodeDictionary - at: stepReport step node methodNode - ifPresent: [ :col | col add: stepReport ] - ifAbsentPut: [ Set with: stepReport ]. - ]. - self tracingPoints: OrderedCollection new. - self tracingPoints addAll: (preconditionNodeDictionary associations collect: [ :asso | ExReqTracingPoint installPreconditionOn: asso key withStepReports: asso value ]). - self tracingPoints addAll: (postconditionNodeDictionary associations collect: [ :asso | ExReqTracingPoint installPostconditionOn: asso key withStepReports: asso value ]). -] - { #category : 'as yet unclassified' } ExReqRepositoryReport >> findRequirementReport: anExReqRequirement [ | result | @@ -128,15 +100,17 @@ ExReqRepositoryReport >> findRequirementReport: anExReqRequirement [ ExReqRepositoryReport >> initialize [ super initialize. - tracingPoints := OrderedCollection new. - announcer := Announcer new + announcer := Announcer new. + builder := NeoExReqInstrumentationBuilder new. ] { #category : 'as yet unclassified' } ExReqRepositoryReport >> installTracingPoints [ - self createTracingPoints. - self tracingPoints do: [ :each | each install ]. + | stepReports | + stepReports := self requirementReports flatCollect: [ :req | + req verificationReports flatCollect: #stepReports ]. + self builder installAllStepReports: stepReports. self isInstalled: true. self isRunning: true. self annouceTracingPointInstalled @@ -157,8 +131,7 @@ ExReqRepositoryReport >> isValid [ { #category : 'as yet unclassified' } ExReqRepositoryReport >> removeTracingPoints [ - self tracingPoints do: [ :each | each remove ]. - self tracingPoints: { }. + self builder uninstallAllStepReports. self isRunning: false. self annouceTracingPointRemoved ] @@ -189,15 +162,3 @@ ExReqRepositoryReport >> subReports [ ^ self requirementReports ] - -{ #category : 'accessing' } -ExReqRepositoryReport >> tracingPoints [ - - ^ tracingPoints -] - -{ #category : 'accessing' } -ExReqRepositoryReport >> tracingPoints: aCollection [ - - tracingPoints := aCollection -] diff --git a/src/ExecutableRequirements/ExReqStepReport.class.st b/src/ExecutableRequirements/ExReqStepReport.class.st index e1bb131..45a339f 100644 --- a/src/ExecutableRequirements/ExReqStepReport.class.st +++ b/src/ExecutableRequirements/ExReqStepReport.class.st @@ -177,6 +177,47 @@ ExReqStepReport >> subReports [ ^ { } ] +{ #category : 'as yet unclassified' } +ExReqStepReport >> verifyPostconditionWithReceiver: anObject withArguments: aCollection [ + + self step ifNil: [ ^ self ]. + postconditionValidity ifTrue: [ ^ self ]. + self preconditionIsValid ifFalse: [ ^ self ]. + self step postcondition ifNil: [ + postconditionValidity := true. + self announceValidity. + ^ self ]. + postconditionValidity := self hasPostcondition + ifTrue: [ + self step postcondition + valueWithEnoughArguments: { + anObject. + aCollection. + self requirement } ] + ifFalse: [ true ]. + + self isValid ifTrue: [ self announceValidity ] +] + +{ #category : 'as yet unclassified' } +ExReqStepReport >> verifyPreconditionWithReceiver: anObject withArguments: aCollection [ + trigger := true. + preconditionValidity ifTrue: [ ^ self ]. + self isPreviousStepValid ifFalse: [ + preconditionValidity := false. + postconditionValidity := false. + ^ self ]. + preconditionValidity := self hasPrecondition + ifTrue: [ + self step precondition + valueWithEnoughArguments: { + anObject. + aCollection. + self requirement } ] + ifFalse: [ true ]. + self isValid ifTrue: [ self announceValidity ] +] + { #category : 'as yet unclassified' } ExReqStepReport >> verifyStepPostconditionWithContext: aContext [ " diff --git a/src/ExecutableRequirements/ExReqTracingPoint.class.st b/src/ExecutableRequirements/ExReqTracingPoint.class.st index 61fde57..90bee58 100644 --- a/src/ExecutableRequirements/ExReqTracingPoint.class.st +++ b/src/ExecutableRequirements/ExReqTracingPoint.class.st @@ -127,7 +127,7 @@ ExReqTracingPoint >> metaLink [ { #category : 'accessing' } ExReqTracingPoint >> name [ - ^ name ifNil: [ #TracingPoint ] + ^ name ifNil: [ name := #TracingPoint ] ] { #category : 'default values' } diff --git a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st new file mode 100644 index 0000000..1576cfe --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st @@ -0,0 +1,173 @@ +Class { + #name : 'NeoExReqInstrumentationBuilder', + #superclass : 'Object', + #instVars : [ + 'preconditionMethodProxies', + 'postconditionMethodProxies', + 'preconditionTracingPoints', + 'postconditionTracingPoints' + ], + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'initialization' } +NeoExReqInstrumentationBuilder >> initialize [ + + super initialize. + preconditionMethodProxies := Dictionary new. + postconditionMethodProxies := Dictionary new. + preconditionTracingPoints := Dictionary new. + postconditionTracingPoints := Dictionary new +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installAllStepReports: aCollection [ + + | tracingPoints methodProxies | + aCollection do: [ :each | self installStepReport: each ]. + tracingPoints := self preconditionTracingPoints values + , self postconditionTracingPoints values. + methodProxies := self preconditionMethodProxies values + , self postconditionMethodProxies values. + + tracingPoints do: [ :each | + each link: each metaLink. + each install ]. + methodProxies do: [ :each | + each + install; + enableInstrumentation ] +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installMethodProxyForStepReport: aStepReport withNode: aNode [ + + self + installPreconditionMethodProxyForStepReport: aStepReport + withNode: aNode. + aStepReport hasPostcondition ifFalse: [ ^ self ]. + self + installPostconditionMethodProxyForStepReport: aStepReport + withNode: aNode +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installPostconditionMethodProxyForStepReport: aStepReport withNode: aNode [ + + self postconditionMethodProxies + at: aNode + ifPresent: [ :p | p handler addStepReport: aStepReport ] + ifAbsentPut: [ + | handler | + handler := NeoExReqPostconditionMethodProxyHandler new + addStepReport: aStepReport; + yourself. + MpMethodProxy onMethod: aNode compiledMethod handler: handler ] +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installPreconditionMethodProxyForStepReport: aStepReport withNode: aNode [ + + self preconditionMethodProxies + at: aNode + ifPresent: [ :p | p handler addStepReport: aStepReport ] + ifAbsentPut: [ + | handler | + handler := NeoExReqPreconditionMethodProxyHandler new + addStepReport: aStepReport; + yourself. + MpMethodProxy onMethod: aNode compiledMethod handler: handler ] +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installStepReport: aStepReport [ + + | astNode | + astNode := aStepReport step node. + astNode isMethod + ifTrue: [ + self installMethodProxyForStepReport: aStepReport withNode: astNode ] + ifFalse: [ + "self + installTracingPointForStepReport: aStepReport + withNode: astNode" ] +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> installTracingPointForStepReport: aStepReport withNode: aNode [ + + self preconditionTracingPoints + at: aNode + ifPresent: [ :tp | tp addStepReport: aStepReport ] + ifAbsentPut: [ + NeoExReqPreconditionTracingPoint new + node: aNode; + addStepReport: aStepReport; + yourself ]. + aStepReport hasPostcondition ifFalse: [ ^ self ]. + self postconditionTracingPoints + at: aNode + ifPresent: [ :tp | tp addStepReport: aStepReport ] + ifAbsentPut: [ + NeoExReqPreconditionTracingPoint new + node: aNode; + addStepReport: aStepReport; + yourself ]. + self + installPostconditionMethodProxyForStepReport: aStepReport + withNode: aNode methodNode. +] + +{ #category : 'testing' } +NeoExReqInstrumentationBuilder >> isEmpty [ + + ^ self preconditionMethodProxies isEmpty and: [self postconditionMethodProxies isEmpty and: [self preconditionTracingPoints isEmpty and: [ self postconditionTracingPoints isEmpty ]]]. +] + +{ #category : 'testing' } +NeoExReqInstrumentationBuilder >> isNotEmpty [ + ^ self isEmpty not +] + +{ #category : 'accessing' } +NeoExReqInstrumentationBuilder >> postconditionMethodProxies [ + + ^ postconditionMethodProxies +] + +{ #category : 'accessing' } +NeoExReqInstrumentationBuilder >> postconditionTracingPoints [ + + ^ postconditionTracingPoints +] + +{ #category : 'accessing' } +NeoExReqInstrumentationBuilder >> preconditionMethodProxies [ + + ^ preconditionMethodProxies +] + +{ #category : 'accessing' } +NeoExReqInstrumentationBuilder >> preconditionTracingPoints [ + + ^ preconditionTracingPoints +] + +{ #category : 'as yet unclassified' } +NeoExReqInstrumentationBuilder >> uninstallAllStepReports [ + + | tracingPoints methodProxies | + tracingPoints := self preconditionTracingPoints values + , self postconditionTracingPoints values. + methodProxies := self preconditionMethodProxies values + , self postconditionMethodProxies values. + + tracingPoints do: [ :each | each uninstall ]. + methodProxies do: [ :each | each uninstall ]. + self preconditionTracingPoints removeAll. + self postconditionTracingPoints removeAll. + self preconditionMethodProxies removeAll. + self postconditionMethodProxies removeAll. +] diff --git a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st new file mode 100644 index 0000000..45443a0 --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st @@ -0,0 +1,9 @@ +Class { + #name : 'NeoExReqMethodProxyHandler', + #superclass : 'MpHandler', + #traits : 'TExReqTracingHandler', + #classTraits : 'TExReqTracingHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} diff --git a/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st new file mode 100644 index 0000000..9ba9bc7 --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st @@ -0,0 +1,15 @@ +Class { + #name : 'NeoExReqPostconditionMethodProxyHandler', + #superclass : 'NeoExReqMethodProxyHandler', + #traits : 'TExReqPostconditionsHandler', + #classTraits : 'TExReqPostconditionsHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +NeoExReqPostconditionMethodProxyHandler >> aboutToReturnWithReceiver: receiver arguments: arguments [ + + self verifyPostconditionsWithReceiver: receiver withArguments: arguments +] diff --git a/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st new file mode 100644 index 0000000..58a6905 --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st @@ -0,0 +1,23 @@ +Class { + #name : 'NeoExReqPostconditionTracingPoint', + #superclass : 'NeoExReqTracingPoint', + #traits : 'TExReqPostconditionsHandler', + #classTraits : 'TExReqPostconditionsHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'accessing' } +NeoExReqPostconditionTracingPoint >> metaLink [ + + ^ super metaLink control: #after; yourself +] + +{ #category : 'as yet unclassified' } +NeoExReqPostconditionTracingPoint >> verifyConditionsWithReceiver: anObject withArguments: aCollection [ + + ^ self + verifyPostconditionsWithReceiver: anObject + withArguments: aCollection +] diff --git a/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st new file mode 100644 index 0000000..849994a --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st @@ -0,0 +1,15 @@ +Class { + #name : 'NeoExReqPreconditionMethodProxyHandler', + #superclass : 'NeoExReqMethodProxyHandler', + #traits : 'TExReqPreconditionsHandler', + #classTraits : 'TExReqPreconditionsHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +NeoExReqPreconditionMethodProxyHandler >> beforeExecutionWithReceiver: anObject arguments: anArrayOfObjects [ + + self verifyPreconditionsWithReceiver: anObject withArguments: anArrayOfObjects +] diff --git a/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st new file mode 100644 index 0000000..53b9b91 --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st @@ -0,0 +1,15 @@ +Class { + #name : 'NeoExReqPreconditionTracingPoint', + #superclass : 'NeoExReqTracingPoint', + #traits : 'TExReqPreconditionsHandler', + #classTraits : 'TExReqPreconditionsHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +NeoExReqPreconditionTracingPoint >> verifyConditionsWithReceiver: anObject withArguments: aCollection [ + + ^ self verifyPreconditionsWithReceiver: anObject withArguments: aCollection +] diff --git a/src/ExecutableRequirements/NeoExReqTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st new file mode 100644 index 0000000..04a30c4 --- /dev/null +++ b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st @@ -0,0 +1,75 @@ +Class { + #name : 'NeoExReqTracingPoint', + #superclass : 'DebugPoint', + #traits : 'TExReqTracingHandler', + #classTraits : 'TExReqTracingHandler classTrait', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +NeoExReqTracingPoint >> disableInstrumentation [ + + self disable +] + +{ #category : 'as yet unclassified' } +NeoExReqTracingPoint >> enableInstrumentation [ + + self enable +] + +{ #category : 'accessing' } +NeoExReqTracingPoint >> metaLink [ + + ^ MetaLink new + metaObject: self; + options: #( #+ optionCompileOnLinkInstallation ); + selector: #verifyConditionsWithContext:; + arguments: #( context ); + yourself +] + +{ #category : 'accessing' } +NeoExReqTracingPoint >> name [ + + ^ name ifNil: [ #TracingPoint ] +] + +{ #category : 'accessing' } +NeoExReqTracingPoint >> type [ + + ^ #TracingPoint +] + +{ #category : 'initialization' } +NeoExReqTracingPoint >> uninstall [ + self remove. +] + +{ #category : 'as yet unclassified' } +NeoExReqTracingPoint >> verifyConditionsWithContext: aContext [ + + + DebugPointManager notifyDebugPointHit: self inContext: aContext. + self enabled ifFalse: [ ^ false ]. + self saveContext: aContext. + (self checkBehaviors allSatisfy: [ :behavior | behavior execute ]) + ifFalse: [ ^ false ]. + self sideEffectBehaviors do: [ :behavior | behavior execute ]. + + self disableInstrumentation. + self + verifyConditionsWithReceiver: aContext receiver + withArguments: aContext arguments. + self enableInstrumentation. + + ^ true +] + +{ #category : 'as yet unclassified' } +NeoExReqTracingPoint >> verifyConditionsWithReceiver: anObject withArguments: aCollection [ + + ^ self subclassResponsibility +] diff --git a/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st b/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st new file mode 100644 index 0000000..e34fd14 --- /dev/null +++ b/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st @@ -0,0 +1,15 @@ +Trait { + #name : 'TExReqPostconditionsHandler', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +TExReqPostconditionsHandler >> verifyPostconditionsWithReceiver: anObject withArguments: aCollection [ + + self stepReports do: [ :stepReport | + stepReport + verifyPostconditionWithReceiver: anObject + withArguments: aCollection ] +] diff --git a/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st b/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st new file mode 100644 index 0000000..562a167 --- /dev/null +++ b/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st @@ -0,0 +1,15 @@ +Trait { + #name : 'TExReqPreconditionsHandler', + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'as yet unclassified' } +TExReqPreconditionsHandler >> verifyPreconditionsWithReceiver: anObject withArguments: aCollection [ + + self stepReports do: [ :stepReport | + stepReport + verifyPreconditionWithReceiver: anObject + withArguments: aCollection ] +] diff --git a/src/ExecutableRequirements/TExReqTracingHandler.trait.st b/src/ExecutableRequirements/TExReqTracingHandler.trait.st new file mode 100644 index 0000000..e80568f --- /dev/null +++ b/src/ExecutableRequirements/TExReqTracingHandler.trait.st @@ -0,0 +1,27 @@ +Trait { + #name : 'TExReqTracingHandler', + #instVars : [ + 'stepReports' + ], + #category : 'ExecutableRequirements-Technical', + #package : 'ExecutableRequirements', + #tag : 'Technical' +} + +{ #category : 'adding' } +TExReqTracingHandler >> addStepReport: aStepReport [ + + self stepReports add: aStepReport +] + +{ #category : 'accessing' } +TExReqTracingHandler >> stepReports [ + + ^ stepReports ifNil: [ stepReports := OrderedCollection new ] +] + +{ #category : 'accessing' } +TExReqTracingHandler >> stepReports: aCollection [ + + stepReports := aCollection +] From 02359b2f0ca723e9437a8dc678abdb2679127960 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 13:59:27 +0200 Subject: [PATCH 2/6] test2 --- .../ExReqRepositoryReportTest.class.st | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st b/src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st index d83f090..f4af9c5 100644 --- a/src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st +++ b/src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st @@ -42,16 +42,6 @@ ExReqRepositoryReportTest >> tearDown [ repository := nil ] -{ #category : 'tests' } -ExReqRepositoryReportTest >> testCreateTracingPoints [ - - self assert: ExReqTracingPoint all isEmpty. - self assert: self report tracingPoints isEmpty. - self report createTracingPoints. - self assert: ExReqTracingPoint all isNotEmpty. - self assert: self report tracingPoints isNotEmpty -] - { #category : 'tests' } ExReqRepositoryReportTest >> testExecuteTracingPoints [ @@ -67,15 +57,11 @@ ExReqRepositoryReportTest >> testExecuteTracingPoints [ { #category : 'tests' } ExReqRepositoryReportTest >> testInstallTracingPoints [ - self assert: ExReqTracingPoint all isEmpty. - self assert: self report tracingPoints isEmpty. + self assert: self report builder isEmpty. self report installTracingPoints. - - self assert: ExReqTracingPoint all isNotEmpty. - self assert: self report tracingPoints isNotEmpty. + self assert: self report builder isNotEmpty. self report removeTracingPoints. - self assert: ExReqTracingPoint all isEmpty. - self assert: self report tracingPoints isEmpty. + self assert: self report builder isEmpty. ] { #category : 'tests' } From 02642c41a979de4578f9564ac5edcbe0dc1ddc2b Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 15:24:14 +0200 Subject: [PATCH 3/6] Add exception through method proxies --- .../ExReqMockTestObject.class.st | 7 +++ .../ExReqSafePassingControlTest.class.st | 29 +++++++++ .../NeoExReqInstrumentationBuilder.class.st | 61 ++++++++----------- .../NeoExReqMethodProxyHandler.class.st | 60 +++++++++++++++++- ...eqPostconditionMethodProxyHandler.class.st | 15 ----- ...NeoExReqPostconditionTracingPoint.class.st | 11 +++- ...ReqPreconditionMethodProxyHandler.class.st | 15 ----- .../NeoExReqPreconditionTracingPoint.class.st | 11 +++- .../NeoExReqTracingPoint.class.st | 25 +++++++- .../TExReqPostconditionsHandler.trait.st | 15 ----- .../TExReqPreconditionsHandler.trait.st | 15 ----- .../TExReqTracingHandler.trait.st | 27 -------- 12 files changed, 159 insertions(+), 132 deletions(-) delete mode 100644 src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st delete mode 100644 src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st delete mode 100644 src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st delete mode 100644 src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st delete mode 100644 src/ExecutableRequirements/TExReqTracingHandler.trait.st diff --git a/src/ExecutableRequirements-Tests/ExReqMockTestObject.class.st b/src/ExecutableRequirements-Tests/ExReqMockTestObject.class.st index 3708ef1..25ac4d1 100644 --- a/src/ExecutableRequirements-Tests/ExReqMockTestObject.class.st +++ b/src/ExecutableRequirements-Tests/ExReqMockTestObject.class.st @@ -15,6 +15,13 @@ ExReqMockTestObject >> methodToTestMetaSafeRecursion [ ^ true ] +{ #category : 'as yet unclassified' } +ExReqMockTestObject >> methodToTestTheExceptionExit [ + + x := [ true ifTrue: [ Exception signal ] ] value. + ^ Color blue +] + { #category : 'as yet unclassified' } ExReqMockTestObject >> methodToTestTheNonLocalReturn [ diff --git a/src/ExecutableRequirements-Tests/ExReqSafePassingControlTest.class.st b/src/ExecutableRequirements-Tests/ExReqSafePassingControlTest.class.st index a914778..9a02fb7 100644 --- a/src/ExecutableRequirements-Tests/ExReqSafePassingControlTest.class.st +++ b/src/ExecutableRequirements-Tests/ExReqSafePassingControlTest.class.st @@ -65,6 +65,23 @@ ExReqSafePassingControlTest >> req3 [ yourself ] +{ #category : 'as yet unclassified' } +ExReqSafePassingControlTest >> req4 [ + + + ^ ExReqRequirement new + title: 'A requirement verifications shall handle exception'; + addVerification: [ :verify | + verify + addStepOnAST: + ((ExReqMockTestObject methodNamed: + #methodToTestTheExceptionExit) ast allChildren select: [ + :each | each isMessage ]) first + withPrecondition: [ true ] + withPostcondition: [ true ] ]; + yourself +] + { #category : 'running' } ExReqSafePassingControlTest >> setUp [ @@ -85,6 +102,18 @@ ExReqSafePassingControlTest >> tearDown [ repository := nil ] +{ #category : 'tests' } +ExReqSafePassingControlTest >> testExceptionExit [ + + | requirement requirementReport | + self report installTracingPoints. + self should: [ExReqMockTestObject new methodToTestTheExceptionExit] raise: Exception. + requirement := self req4. + requirementReport := self report findRequirementReport: requirement. + self assert: requirementReport isValid. + self report removeTracingPoints +] + { #category : 'tests' } ExReqSafePassingControlTest >> testMetaSafeRecursion [ diff --git a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st index 1576cfe..de8fe31 100644 --- a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st +++ b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st @@ -2,10 +2,9 @@ Class { #name : 'NeoExReqInstrumentationBuilder', #superclass : 'Object', #instVars : [ - 'preconditionMethodProxies', - 'postconditionMethodProxies', 'preconditionTracingPoints', - 'postconditionTracingPoints' + 'postconditionTracingPoints', + 'methodProxies' ], #category : 'ExecutableRequirements-Technical', #package : 'ExecutableRequirements', @@ -16,8 +15,7 @@ Class { NeoExReqInstrumentationBuilder >> initialize [ super initialize. - preconditionMethodProxies := Dictionary new. - postconditionMethodProxies := Dictionary new. + methodProxies := Dictionary new. preconditionTracingPoints := Dictionary new. postconditionTracingPoints := Dictionary new ] @@ -25,17 +23,15 @@ NeoExReqInstrumentationBuilder >> initialize [ { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> installAllStepReports: aCollection [ - | tracingPoints methodProxies | + | tracingPoints | aCollection do: [ :each | self installStepReport: each ]. tracingPoints := self preconditionTracingPoints values , self postconditionTracingPoints values. - methodProxies := self preconditionMethodProxies values - , self postconditionMethodProxies values. tracingPoints do: [ :each | each link: each metaLink. each install ]. - methodProxies do: [ :each | + self methodProxies valuesDo: [ :each | each install; enableInstrumentation ] @@ -56,13 +52,13 @@ NeoExReqInstrumentationBuilder >> installMethodProxyForStepReport: aStepReport w { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> installPostconditionMethodProxyForStepReport: aStepReport withNode: aNode [ - self postconditionMethodProxies + self methodProxies at: aNode - ifPresent: [ :p | p handler addStepReport: aStepReport ] + ifPresent: [ :p | p handler addPostconditionStepReport: aStepReport ] ifAbsentPut: [ | handler | - handler := NeoExReqPostconditionMethodProxyHandler new - addStepReport: aStepReport; + handler := NeoExReqMethodProxyHandler new + addPostconditionStepReport: aStepReport; yourself. MpMethodProxy onMethod: aNode compiledMethod handler: handler ] ] @@ -70,13 +66,13 @@ NeoExReqInstrumentationBuilder >> installPostconditionMethodProxyForStepReport: { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> installPreconditionMethodProxyForStepReport: aStepReport withNode: aNode [ - self preconditionMethodProxies + self methodProxies at: aNode - ifPresent: [ :p | p handler addStepReport: aStepReport ] + ifPresent: [ :p | p handler addPreconditionStepReport: aStepReport ] ifAbsentPut: [ | handler | - handler := NeoExReqPreconditionMethodProxyHandler new - addStepReport: aStepReport; + handler := NeoExReqMethodProxyHandler new + addPreconditionStepReport: aStepReport; yourself. MpMethodProxy onMethod: aNode compiledMethod handler: handler ] ] @@ -87,12 +83,12 @@ NeoExReqInstrumentationBuilder >> installStepReport: aStepReport [ | astNode | astNode := aStepReport step node. astNode isMethod - ifTrue: [ - self installMethodProxyForStepReport: aStepReport withNode: astNode ] + ifTrue: [ self installMethodProxyForStepReport: aStepReport withNode: astNode + ] ifFalse: [ - "self + self installTracingPointForStepReport: aStepReport - withNode: astNode" ] + withNode: astNode ] ] { #category : 'as yet unclassified' } @@ -123,7 +119,9 @@ NeoExReqInstrumentationBuilder >> installTracingPointForStepReport: aStepReport { #category : 'testing' } NeoExReqInstrumentationBuilder >> isEmpty [ - ^ self preconditionMethodProxies isEmpty and: [self postconditionMethodProxies isEmpty and: [self preconditionTracingPoints isEmpty and: [ self postconditionTracingPoints isEmpty ]]]. + ^ self methodProxies isEmpty and: [ + self preconditionTracingPoints isEmpty and: [ + self postconditionTracingPoints isEmpty ] ] ] { #category : 'testing' } @@ -132,9 +130,9 @@ NeoExReqInstrumentationBuilder >> isNotEmpty [ ] { #category : 'accessing' } -NeoExReqInstrumentationBuilder >> postconditionMethodProxies [ +NeoExReqInstrumentationBuilder >> methodProxies [ - ^ postconditionMethodProxies + ^ methodProxies ] { #category : 'accessing' } @@ -143,12 +141,6 @@ NeoExReqInstrumentationBuilder >> postconditionTracingPoints [ ^ postconditionTracingPoints ] -{ #category : 'accessing' } -NeoExReqInstrumentationBuilder >> preconditionMethodProxies [ - - ^ preconditionMethodProxies -] - { #category : 'accessing' } NeoExReqInstrumentationBuilder >> preconditionTracingPoints [ @@ -158,16 +150,13 @@ NeoExReqInstrumentationBuilder >> preconditionTracingPoints [ { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> uninstallAllStepReports [ - | tracingPoints methodProxies | + | tracingPoints | tracingPoints := self preconditionTracingPoints values , self postconditionTracingPoints values. - methodProxies := self preconditionMethodProxies values - , self postconditionMethodProxies values. tracingPoints do: [ :each | each uninstall ]. - methodProxies do: [ :each | each uninstall ]. + self methodProxies valuesDo: [ :each | each uninstall ]. self preconditionTracingPoints removeAll. self postconditionTracingPoints removeAll. - self preconditionMethodProxies removeAll. - self postconditionMethodProxies removeAll. + self methodProxies removeAll ] diff --git a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st index 45443a0..4f57597 100644 --- a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st +++ b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st @@ -1,9 +1,65 @@ Class { #name : 'NeoExReqMethodProxyHandler', #superclass : 'MpHandler', - #traits : 'TExReqTracingHandler', - #classTraits : 'TExReqTracingHandler classTrait', + #instVars : [ + 'postconditionStepReports', + 'preconditionStepReports' + ], #category : 'ExecutableRequirements-Technical', #package : 'ExecutableRequirements', #tag : 'Technical' } + +{ #category : 'evaluating' } +NeoExReqMethodProxyHandler >> aboutToReturnWithReceiver: anObject arguments: anArrayOfObjects [ + + self postconditionStepReports do: [ :stepReport | + stepReport + verifyPostconditionWithReceiver: anObject + withArguments: anArrayOfObjects ] +] + +{ #category : 'adding' } +NeoExReqMethodProxyHandler >> addPostconditionStepReport: aStepReport [ + + self postconditionStepReports add: aStepReport +] + +{ #category : 'adding' } +NeoExReqMethodProxyHandler >> addPreconditionStepReport: aStepReport [ + + self preconditionStepReports add: aStepReport +] + +{ #category : 'evaluating' } +NeoExReqMethodProxyHandler >> afterExecutionWithReceiver: anObject arguments: anArrayOfObjects returnValue: aReturnValue [ + + self postconditionStepReports do: [ :stepReport | + stepReport + verifyPostconditionWithReceiver: anObject + withArguments: anArrayOfObjects ]. + ^ aReturnValue +] + +{ #category : 'evaluating' } +NeoExReqMethodProxyHandler >> beforeExecutionWithReceiver: anObject arguments: anArrayOfObjects [ + + self preconditionStepReports , self postconditionStepReports do: [ :stepReport | + stepReport + verifyPreconditionWithReceiver: anObject + withArguments: anArrayOfObjects ] +] + +{ #category : 'accessing' } +NeoExReqMethodProxyHandler >> postconditionStepReports [ + + ^ postconditionStepReports ifNil: [ postconditionStepReports := OrderedCollection new ]. + +] + +{ #category : 'accessing' } +NeoExReqMethodProxyHandler >> preconditionStepReports [ + + ^ preconditionStepReports ifNil: [ preconditionStepReports := OrderedCollection new ]. + +] diff --git a/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st deleted file mode 100644 index 9ba9bc7..0000000 --- a/src/ExecutableRequirements/NeoExReqPostconditionMethodProxyHandler.class.st +++ /dev/null @@ -1,15 +0,0 @@ -Class { - #name : 'NeoExReqPostconditionMethodProxyHandler', - #superclass : 'NeoExReqMethodProxyHandler', - #traits : 'TExReqPostconditionsHandler', - #classTraits : 'TExReqPostconditionsHandler classTrait', - #category : 'ExecutableRequirements-Technical', - #package : 'ExecutableRequirements', - #tag : 'Technical' -} - -{ #category : 'as yet unclassified' } -NeoExReqPostconditionMethodProxyHandler >> aboutToReturnWithReceiver: receiver arguments: arguments [ - - self verifyPostconditionsWithReceiver: receiver withArguments: arguments -] diff --git a/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st index 58a6905..c0ba5d9 100644 --- a/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st +++ b/src/ExecutableRequirements/NeoExReqPostconditionTracingPoint.class.st @@ -1,8 +1,6 @@ Class { #name : 'NeoExReqPostconditionTracingPoint', #superclass : 'NeoExReqTracingPoint', - #traits : 'TExReqPostconditionsHandler', - #classTraits : 'TExReqPostconditionsHandler classTrait', #category : 'ExecutableRequirements-Technical', #package : 'ExecutableRequirements', #tag : 'Technical' @@ -21,3 +19,12 @@ NeoExReqPostconditionTracingPoint >> verifyConditionsWithReceiver: anObject with verifyPostconditionsWithReceiver: anObject withArguments: aCollection ] + +{ #category : 'as yet unclassified' } +NeoExReqPostconditionTracingPoint >> verifyPostconditionsWithReceiver: anObject withArguments: aCollection [ + + self stepReports do: [ :stepReport | + stepReport + verifyPostconditionWithReceiver: anObject + withArguments: aCollection ] +] diff --git a/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st deleted file mode 100644 index 849994a..0000000 --- a/src/ExecutableRequirements/NeoExReqPreconditionMethodProxyHandler.class.st +++ /dev/null @@ -1,15 +0,0 @@ -Class { - #name : 'NeoExReqPreconditionMethodProxyHandler', - #superclass : 'NeoExReqMethodProxyHandler', - #traits : 'TExReqPreconditionsHandler', - #classTraits : 'TExReqPreconditionsHandler classTrait', - #category : 'ExecutableRequirements-Technical', - #package : 'ExecutableRequirements', - #tag : 'Technical' -} - -{ #category : 'as yet unclassified' } -NeoExReqPreconditionMethodProxyHandler >> beforeExecutionWithReceiver: anObject arguments: anArrayOfObjects [ - - self verifyPreconditionsWithReceiver: anObject withArguments: anArrayOfObjects -] diff --git a/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st index 53b9b91..61c5c47 100644 --- a/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st +++ b/src/ExecutableRequirements/NeoExReqPreconditionTracingPoint.class.st @@ -1,8 +1,6 @@ Class { #name : 'NeoExReqPreconditionTracingPoint', #superclass : 'NeoExReqTracingPoint', - #traits : 'TExReqPreconditionsHandler', - #classTraits : 'TExReqPreconditionsHandler classTrait', #category : 'ExecutableRequirements-Technical', #package : 'ExecutableRequirements', #tag : 'Technical' @@ -13,3 +11,12 @@ NeoExReqPreconditionTracingPoint >> verifyConditionsWithReceiver: anObject withA ^ self verifyPreconditionsWithReceiver: anObject withArguments: aCollection ] + +{ #category : 'as yet unclassified' } +NeoExReqPreconditionTracingPoint >> verifyPreconditionsWithReceiver: anObject withArguments: aCollection [ + + self stepReports do: [ :stepReport | + stepReport + verifyPreconditionWithReceiver: anObject + withArguments: aCollection ] +] diff --git a/src/ExecutableRequirements/NeoExReqTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st index 04a30c4..16dcdae 100644 --- a/src/ExecutableRequirements/NeoExReqTracingPoint.class.st +++ b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st @@ -1,13 +1,20 @@ Class { #name : 'NeoExReqTracingPoint', #superclass : 'DebugPoint', - #traits : 'TExReqTracingHandler', - #classTraits : 'TExReqTracingHandler classTrait', + #instVars : [ + 'stepReports' + ], #category : 'ExecutableRequirements-Technical', #package : 'ExecutableRequirements', #tag : 'Technical' } +{ #category : 'adding' } +NeoExReqTracingPoint >> addStepReport: aStepReport [ + + self stepReports add: aStepReport +] + { #category : 'as yet unclassified' } NeoExReqTracingPoint >> disableInstrumentation [ @@ -37,6 +44,18 @@ NeoExReqTracingPoint >> name [ ^ name ifNil: [ #TracingPoint ] ] +{ #category : 'accessing' } +NeoExReqTracingPoint >> stepReports [ + + ^ stepReports ifNil: [ stepReports := OrderedCollection new ] +] + +{ #category : 'accessing' } +NeoExReqTracingPoint >> stepReports: aCollection [ + + stepReports := aCollection +] + { #category : 'accessing' } NeoExReqTracingPoint >> type [ @@ -52,7 +71,7 @@ NeoExReqTracingPoint >> uninstall [ NeoExReqTracingPoint >> verifyConditionsWithContext: aContext [ - DebugPointManager notifyDebugPointHit: self inContext: aContext. + "DebugPointManager notifyDebugPointHit: self inContext: aContext." self enabled ifFalse: [ ^ false ]. self saveContext: aContext. (self checkBehaviors allSatisfy: [ :behavior | behavior execute ]) diff --git a/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st b/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st deleted file mode 100644 index e34fd14..0000000 --- a/src/ExecutableRequirements/TExReqPostconditionsHandler.trait.st +++ /dev/null @@ -1,15 +0,0 @@ -Trait { - #name : 'TExReqPostconditionsHandler', - #category : 'ExecutableRequirements-Technical', - #package : 'ExecutableRequirements', - #tag : 'Technical' -} - -{ #category : 'as yet unclassified' } -TExReqPostconditionsHandler >> verifyPostconditionsWithReceiver: anObject withArguments: aCollection [ - - self stepReports do: [ :stepReport | - stepReport - verifyPostconditionWithReceiver: anObject - withArguments: aCollection ] -] diff --git a/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st b/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st deleted file mode 100644 index 562a167..0000000 --- a/src/ExecutableRequirements/TExReqPreconditionsHandler.trait.st +++ /dev/null @@ -1,15 +0,0 @@ -Trait { - #name : 'TExReqPreconditionsHandler', - #category : 'ExecutableRequirements-Technical', - #package : 'ExecutableRequirements', - #tag : 'Technical' -} - -{ #category : 'as yet unclassified' } -TExReqPreconditionsHandler >> verifyPreconditionsWithReceiver: anObject withArguments: aCollection [ - - self stepReports do: [ :stepReport | - stepReport - verifyPreconditionWithReceiver: anObject - withArguments: aCollection ] -] diff --git a/src/ExecutableRequirements/TExReqTracingHandler.trait.st b/src/ExecutableRequirements/TExReqTracingHandler.trait.st deleted file mode 100644 index e80568f..0000000 --- a/src/ExecutableRequirements/TExReqTracingHandler.trait.st +++ /dev/null @@ -1,27 +0,0 @@ -Trait { - #name : 'TExReqTracingHandler', - #instVars : [ - 'stepReports' - ], - #category : 'ExecutableRequirements-Technical', - #package : 'ExecutableRequirements', - #tag : 'Technical' -} - -{ #category : 'adding' } -TExReqTracingHandler >> addStepReport: aStepReport [ - - self stepReports add: aStepReport -] - -{ #category : 'accessing' } -TExReqTracingHandler >> stepReports [ - - ^ stepReports ifNil: [ stepReports := OrderedCollection new ] -] - -{ #category : 'accessing' } -TExReqTracingHandler >> stepReports: aCollection [ - - stepReports := aCollection -] From db45b69034b3cc98c7b372714c4f686313ae74b3 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 17:06:06 +0200 Subject: [PATCH 4/6] Add safe removal of breakpoints --- .../NeoExReqInstrumentationBuilder.class.st | 2 +- src/ExecutableRequirements/NeoExReqTracingPoint.class.st | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st index de8fe31..047b8e2 100644 --- a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st +++ b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st @@ -154,8 +154,8 @@ NeoExReqInstrumentationBuilder >> uninstallAllStepReports [ tracingPoints := self preconditionTracingPoints values , self postconditionTracingPoints values. - tracingPoints do: [ :each | each uninstall ]. self methodProxies valuesDo: [ :each | each uninstall ]. + tracingPoints do: [ :each | each uninstall ]. self preconditionTracingPoints removeAll. self postconditionTracingPoints removeAll. self methodProxies removeAll diff --git a/src/ExecutableRequirements/NeoExReqTracingPoint.class.st b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st index 16dcdae..d975084 100644 --- a/src/ExecutableRequirements/NeoExReqTracingPoint.class.st +++ b/src/ExecutableRequirements/NeoExReqTracingPoint.class.st @@ -64,7 +64,8 @@ NeoExReqTracingPoint >> type [ { #category : 'initialization' } NeoExReqTracingPoint >> uninstall [ - self remove. + + thisProcess runInMetaLevel: [ self remove ] ] { #category : 'as yet unclassified' } From a6fd633356d3fa696656cc2288ccf1918da72216 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 18:33:08 +0200 Subject: [PATCH 5/6] Fix precondition not being triggered. --- .../NeoExReqInstrumentationBuilder.class.st | 12 +++++++----- .../NeoExReqMethodProxyHandler.class.st | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st index 047b8e2..5174adc 100644 --- a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st +++ b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st @@ -94,6 +94,11 @@ NeoExReqInstrumentationBuilder >> installStepReport: aStepReport [ { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> installTracingPointForStepReport: aStepReport withNode: aNode [ + "Quand la postcondition est nil, il ne trigger pas sauf si on retire la method proxy." + "L'installation de la méthode proxy retire le preconditionTracingPoint". + self + installPostconditionMethodProxyForStepReport: aStepReport + withNode: aNode methodNode. self preconditionTracingPoints at: aNode ifPresent: [ :tp | tp addStepReport: aStepReport ] @@ -107,13 +112,10 @@ NeoExReqInstrumentationBuilder >> installTracingPointForStepReport: aStepReport at: aNode ifPresent: [ :tp | tp addStepReport: aStepReport ] ifAbsentPut: [ - NeoExReqPreconditionTracingPoint new + NeoExReqPostconditionTracingPoint new node: aNode; addStepReport: aStepReport; - yourself ]. - self - installPostconditionMethodProxyForStepReport: aStepReport - withNode: aNode methodNode. + yourself ] ] { #category : 'testing' } diff --git a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st index 4f57597..3f124d8 100644 --- a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st +++ b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st @@ -44,7 +44,8 @@ NeoExReqMethodProxyHandler >> afterExecutionWithReceiver: anObject arguments: an { #category : 'evaluating' } NeoExReqMethodProxyHandler >> beforeExecutionWithReceiver: anObject arguments: anArrayOfObjects [ - self preconditionStepReports , self postconditionStepReports do: [ :stepReport | + self preconditionStepReports , self postconditionStepReports do: [ + :stepReport | stepReport verifyPreconditionWithReceiver: anObject withArguments: anArrayOfObjects ] From 2617b29eaed4da8ac7d9ff1f4d571a2f87afd8f4 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Tue, 6 May 2025 18:54:39 +0200 Subject: [PATCH 6/6] C'est bug :( --- .../NeoExReqInstrumentationBuilder.class.st | 13 +++++++------ .../NeoExReqMethodProxyHandler.class.st | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st index 5174adc..95d5440 100644 --- a/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st +++ b/src/ExecutableRequirements/NeoExReqInstrumentationBuilder.class.st @@ -83,8 +83,8 @@ NeoExReqInstrumentationBuilder >> installStepReport: aStepReport [ | astNode | astNode := aStepReport step node. astNode isMethod - ifTrue: [ self installMethodProxyForStepReport: aStepReport withNode: astNode - ] + ifTrue: [ + "self installMethodProxyForStepReport: aStepReport withNode: astNode" ] ifFalse: [ self installTracingPointForStepReport: aStepReport @@ -93,12 +93,13 @@ NeoExReqInstrumentationBuilder >> installStepReport: aStepReport [ { #category : 'as yet unclassified' } NeoExReqInstrumentationBuilder >> installTracingPointForStepReport: aStepReport withNode: aNode [ - "Quand la postcondition est nil, il ne trigger pas sauf si on retire la method proxy." - "L'installation de la méthode proxy retire le preconditionTracingPoint". - self + + "L'installation de la méthode proxy retire le preconditionTracingPoint" + + "self installPostconditionMethodProxyForStepReport: aStepReport - withNode: aNode methodNode. + withNode: aNode methodNode." self preconditionTracingPoints at: aNode ifPresent: [ :tp | tp addStepReport: aStepReport ] diff --git a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st index 3f124d8..30456ce 100644 --- a/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st +++ b/src/ExecutableRequirements/NeoExReqMethodProxyHandler.class.st @@ -44,7 +44,7 @@ NeoExReqMethodProxyHandler >> afterExecutionWithReceiver: anObject arguments: an { #category : 'evaluating' } NeoExReqMethodProxyHandler >> beforeExecutionWithReceiver: anObject arguments: anArrayOfObjects [ - self preconditionStepReports , self postconditionStepReports do: [ + self preconditionStepReports do: [ :stepReport | stepReport verifyPreconditionWithReceiver: anObject