From 15fe9f1e33a7dc68d8a5071f617a902357b397d7 Mon Sep 17 00:00:00 2001 From: David Bajger <45875448+Bajger@users.noreply.github.com> Date: Tue, 16 May 2023 14:35:38 +0200 Subject: [PATCH] 574 add support for p11 and remove support for versions 7 8 (#575) Removed support for Pharo versions P7, P8 added for P11 - fixes #574 * Changed CI to use P11-P9, readme updated - added CI support for P11-P9 - adjusted readme with proper badges * Added compatibility package for P11 handling ExTonelWriter superclass change * Fixed method classification * Fixed baseline with version specific loading --- .github/workflows/ci.yml | 2 +- README.md | 7 +- .../BaselineOfExercism.class.st | 29 +++----- .../ExercismPharo110/ExTonelWriter.class.st | 67 +++++++++++++++++++ dev/src/ExercismPharo110/package.st | 1 + .../ClassNotUnderstood.class.st | 32 --------- .../DoesNotUnderstandDebugAction.extension.st | 62 ----------------- .../ManifestExercismPharo.class.st | 13 ---- .../UndefinedObject.extension.st | 34 ---------- dev/src/ExercismPharo70/package.st | 1 - dev/src/ExercismPharo80/Path.extension.st | 8 --- dev/src/ExercismPharo80/package.st | 1 - 12 files changed, 84 insertions(+), 173 deletions(-) create mode 100644 dev/src/ExercismPharo110/ExTonelWriter.class.st create mode 100644 dev/src/ExercismPharo110/package.st delete mode 100644 dev/src/ExercismPharo70/ClassNotUnderstood.class.st delete mode 100644 dev/src/ExercismPharo70/DoesNotUnderstandDebugAction.extension.st delete mode 100644 dev/src/ExercismPharo70/ManifestExercismPharo.class.st delete mode 100644 dev/src/ExercismPharo70/UndefinedObject.extension.st delete mode 100644 dev/src/ExercismPharo70/package.st delete mode 100644 dev/src/ExercismPharo80/Path.extension.st delete mode 100644 dev/src/ExercismPharo80/package.st diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5602d398..aedfaffc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - smalltalk: [ Pharo64-10, Pharo64-9.0, Pharo64-8.0 ] + smalltalk: [Pharo64-11, Pharo64-10, Pharo64-9.0] name: ${{ matrix.smalltalk }} steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 9c27cfae..f3aaeab9 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ [![Build & Unit tests](https://github.com/exercism/pharo-smalltalk/actions/workflows/ci.yml/badge.svg)](https://github.com/exercism/pharo-smalltalk/actions/workflows/ci.yml) [![GitHub release](https://img.shields.io/github/release/exercism/pharo-smalltalk.svg)](https://github.com/exercism/pharo-smalltalk/releases/latest) -[![Pharo 10](https://img.shields.io/badge/Pharo-10-informational)](https://get.pharo.org) -[![Pharo 9.0](https://img.shields.io/badge/Pharo-9.0-informational)](https://get.pharo.org/64) -[![Pharo 8.0](https://img.shields.io/badge/Pharo-8.0-informational)](https://get.pharo.org/archive/80) +[![Pharo 11](https://img.shields.io/badge/Pharo-11-informational)](https://get.pharo.org) +[![Pharo 10](https://img.shields.io/badge/Pharo-10-informational)](https://get.pharo.org/100+vm) +[![Pharo 9.0](https://img.shields.io/badge/Pharo-9.0-informational)](https://get.pharo.org/90+vm) + This repository is for the development of [Exercism](http://exercism.io) exercises running in the [Pharo Smalltalk](http://pharo.org) programming environment. diff --git a/dev/src/BaselineOfExercism/BaselineOfExercism.class.st b/dev/src/BaselineOfExercism/BaselineOfExercism.class.st index 13c6cc0b..977ede74 100644 --- a/dev/src/BaselineOfExercism/BaselineOfExercism.class.st +++ b/dev/src/BaselineOfExercism/BaselineOfExercism.class.st @@ -55,24 +55,17 @@ BaselineOfExercism >> baseline: spec [ with: #('ExercismDev' 'ExercismWIP' 'ExercismSystemTests'); group: 'testRunner' with: #('ExercismTestRunner'); group: 'testRunnerTests' with: #('ExercismTestRunnerTests'); - group: 'v3' with: #('ExercismV3') ]. - spec - for: #'pharo7.x' - do: [ spec - package: 'ExercismPharo70'; - "Pharo override/patch methods" - package: 'ExercismTools' - with: [ spec requires: #('ExercismPharo70') ]; - package: 'ExercismDev' - with: - [ spec requires: #('Ring2') "For mentoring support of shadow browsing" ] ]. - spec - for: #'pharo8.x' - do: [ spec - package: 'ExercismPharo80'; - package: 'ExercismTools' - with: [ spec requires: #('ExercismPharo80') ] ]. - spec for: #'pharo9.x' do: [ spec package: 'ExercismPharo90' ] + group: 'v3' with: #('ExercismV3') + ]. + spec for: #'pharo9.x' do: [ + spec package: 'ExercismTools' with: [ spec includes: #('ExercismPharo90') ]. + spec package: 'ExercismPharo90' ]. + spec for: #'pharo11.x' do: [ + "ExercismTools must be loaded prior compatibilty package, to overwrite original class definition of ExTonelWriter" + spec package: 'ExercismTools' with: [ spec includes: #('ExercismPharo110') ]. + spec package: 'ExercismPharo110' with: [ spec requires: 'ExercismTools' ] + ] + ] { #category : #baselines } diff --git a/dev/src/ExercismPharo110/ExTonelWriter.class.st b/dev/src/ExercismPharo110/ExTonelWriter.class.st new file mode 100644 index 00000000..a0f4d923 --- /dev/null +++ b/dev/src/ExercismPharo110/ExTonelWriter.class.st @@ -0,0 +1,67 @@ +" +I am a TonelWriter that provides finer level control of writing Tonel files for Exercism +" +Class { + #name : #ExTonelWriter, + #superclass : #TonelWriterV1, + #instVars : [ + 'sourceDirectory' + ], + #category : #ExercismPharo110 +} + +{ #category : #writing } +ExTonelWriter >> mappedSnapshot: aSnapshot [ + "extracted from #writeSnapshot: to customise behavior" + + |tonelMap extensionDefinitions| + snapshot := aSnapshot. + tonelMap := Dictionary new. + + "Tonel export classes with their methods, mapped from their filename to content streams" + (snapshot definitions select: #isClassDefinition) + do: [ :classDef | |filename tonelStream| + filename := classDef exTonelFilename. + tonelStream := WriteStream on: String new. + self writeClass: classDef on: tonelStream. + tonelMap at: filename put: tonelStream ]. + + "... and method extensions" + extensionDefinitions := (snapshot definitions select: [ :each | + each isMethodDefinition and: [ each isExtensionMethod ] ]) removeDuplicates. + + extensionDefinitions do: [ :methodDef | |filename| + filename := methodDef exTonelFilename. + tonelMap at: filename ifAbsentPut: [ + (WriteStream on: String new) nextPutAll: 'Extension { #name : #', methodDef className, ' }' ; lf; yourself ]. + self writeMethodDefinition: methodDef on: (tonelMap at: filename). + ]. + ^tonelMap + +] + +{ #category : #private } +ExTonelWriter >> obtainPackageDir: aDefinition [ + "Overridden to allow a specific directory to be supplied" + + ^self sourceDirectory ifNil: [ super obtainPackageDir: aDefinition ] +] + +{ #category : #accessing } +ExTonelWriter >> sourceDirectory [ + ^ sourceDirectory +] + +{ #category : #accessing } +ExTonelWriter >> sourceDirectory: anObject [ + sourceDirectory := anObject +] + +{ #category : #writing } +ExTonelWriter >> writeClass: aClassDefinition on: aStream [ + "Not clear on whether this is an override and still needed? ~tma~" + + self writeClassDefinition: aClassDefinition on: aStream. + self writeClassSideMethodDefinitions: aClassDefinition on: aStream. + self writeInstanceSideMethodDefinitions: aClassDefinition on: aStream +] diff --git a/dev/src/ExercismPharo110/package.st b/dev/src/ExercismPharo110/package.st new file mode 100644 index 00000000..f1f5d86e --- /dev/null +++ b/dev/src/ExercismPharo110/package.st @@ -0,0 +1 @@ +Package { #name : #ExercismPharo110 } diff --git a/dev/src/ExercismPharo70/ClassNotUnderstood.class.st b/dev/src/ExercismPharo70/ClassNotUnderstood.class.st deleted file mode 100644 index 10f333c0..00000000 --- a/dev/src/ExercismPharo70/ClassNotUnderstood.class.st +++ /dev/null @@ -1,32 +0,0 @@ -Class { - #name : #ClassNotUnderstood, - #superclass : #MessageNotUnderstood, - #instVars : [ - 'variableNode' - ], - #category : #ExercismPharo70 -} - -{ #category : #accessing } -ClassNotUnderstood >> classSymbol [ - ^ self variableNode name -] - -{ #category : #accessing } -ClassNotUnderstood >> smartDescription [ - - message ifNil: [^self description]. - - ^self classSymbol printString - , ' is missing, and does not understand ', message selector printString -] - -{ #category : #accessing } -ClassNotUnderstood >> variableNode [ - ^ variableNode -] - -{ #category : #accessing } -ClassNotUnderstood >> variableNode: anObject [ - variableNode := anObject -] diff --git a/dev/src/ExercismPharo70/DoesNotUnderstandDebugAction.extension.st b/dev/src/ExercismPharo70/DoesNotUnderstandDebugAction.extension.st deleted file mode 100644 index 60589998..00000000 --- a/dev/src/ExercismPharo70/DoesNotUnderstandDebugAction.extension.st +++ /dev/null @@ -1,62 +0,0 @@ -Extension { #name : #DoesNotUnderstandDebugAction } - -{ #category : #'*ExercismPharo70' } -DoesNotUnderstandDebugAction >> createMissingClassWith: variableNode in: aContext [ - | previousContext | - - OCUndeclaredVariableWarning new - node: variableNode; - defineClass: variableNode name. - - previousContext := aContext stack second. - - self closeWindow. - - previousContext restart -] - -{ #category : #'*ExercismPharo70' } -DoesNotUnderstandDebugAction >> defaultProtocol [ - "Facilitate DNU with TDD creating extension methods by suggesting that as default protocol" - | interruptedContext candidateContext | - interruptedContext := self interruptedContext. - candidateContext := interruptedContext sender. - [ candidateContext isNil or: [ candidateContext contextClass isKindOf: TestCase class ] ] - whileFalse: [ candidateContext := candidateContext sender ]. - candidateContext ifNotNil: [ - | testPackage dnuPackage| - dnuPackage := interruptedContext receiver class package. - testPackage := candidateContext contextClass package. - (testPackage = dnuPackage) ifFalse: [ ^ '*', testPackage name ]. - ]. - ^'as yet unclassified' - - -] - -{ #category : #'*ExercismPharo70' } -DoesNotUnderstandDebugAction >> executeAction [ - "Should only be called when the debugger was created in response to a - MessageNotUnderstood exception. Create a stub for the method that was - missing and proceed into it, or create a class if it was missing instead" - - | msg msgCategory chosenClass exception | - - msg := self interruptedContext tempAt: 1. - exception := self interruptedContext tempAt: 2. - - (exception class == ClassNotUnderstood) ifTrue: [ - self createMissingClassWith: exception variableNode in: self interruptedContext ]. - - chosenClass := self - askForSuperclassOf: self interruptedContext receiver class - toImplement: msg selector - ifCancel: [^self]. - msgCategory := (self askForCategoryIn: chosenClass default: self defaultProtocol). - self session - implement: msg - classified: msgCategory - inClass: chosenClass - forContext: self interruptedContext. - self debugger selectTopContext -] diff --git a/dev/src/ExercismPharo70/ManifestExercismPharo.class.st b/dev/src/ExercismPharo70/ManifestExercismPharo.class.st deleted file mode 100644 index 746e5a51..00000000 --- a/dev/src/ExercismPharo70/ManifestExercismPharo.class.st +++ /dev/null @@ -1,13 +0,0 @@ -" -I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser -" -Class { - #name : #ManifestExercismPharo, - #superclass : #PackageManifest, - #category : #'ExercismPharo70-Manifest' -} - -{ #category : #'code-critics' } -ManifestExercismPharo class >> ruleRBBadMessageRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#DoesNotUnderstandDebugAction #defaultProtocol #false)) #'2019-05-12T13:53:13.954721+08:00') ) -] diff --git a/dev/src/ExercismPharo70/UndefinedObject.extension.st b/dev/src/ExercismPharo70/UndefinedObject.extension.st deleted file mode 100644 index ae3cfebf..00000000 --- a/dev/src/ExercismPharo70/UndefinedObject.extension.st +++ /dev/null @@ -1,34 +0,0 @@ -Extension { #name : #UndefinedObject } - -{ #category : #'*ExercismPharo70' } -UndefinedObject >> doesNotUnderstand: aMessage [ - - "Handle the fact that there was an attempt to send the given message to an Undeclared variable (nil), hence the receiver does not understand this message (typically #new)." - "Testing: (3 activeProcess)" - - | exception resumeValue node | - - (node := self findUndeclaredVariableIn: thisContext sender sourceNodeExecuted) ifNil: [ - ^super doesNotUnderstand: aMessage ]. - - (exception := ClassNotUnderstood new) - message: aMessage; - variableNode: node; - receiver: self. - - resumeValue := exception signal. - ^ exception reachedDefaultHandler - ifTrue: [ aMessage sentTo: self ] - ifFalse: [ resumeValue ] . - - -] - -{ #category : #'*ExercismPharo70' } -UndefinedObject >> findUndeclaredVariableIn: ast [ - - ast nodesDo: [:n | - (n isVariable and: [ n isUndeclared]) ifTrue: [ ^n ]]. - - ^nil -] diff --git a/dev/src/ExercismPharo70/package.st b/dev/src/ExercismPharo70/package.st deleted file mode 100644 index e434a7df..00000000 --- a/dev/src/ExercismPharo70/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #ExercismPharo70 } diff --git a/dev/src/ExercismPharo80/Path.extension.st b/dev/src/ExercismPharo80/Path.extension.st deleted file mode 100644 index f7628920..00000000 --- a/dev/src/ExercismPharo80/Path.extension.st +++ /dev/null @@ -1,8 +0,0 @@ -Extension { #name : #Path } - -{ #category : #'*ExercismPharo80' } -Path class >> delimiter [ - "This is for backward compatibility with P8" - - ^ self delimeter -] diff --git a/dev/src/ExercismPharo80/package.st b/dev/src/ExercismPharo80/package.st deleted file mode 100644 index f5cfc15e..00000000 --- a/dev/src/ExercismPharo80/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #ExercismPharo80 }