diff --git a/src/Dynabook-SmalltalkCI/SdScriptFunctionCall.class.st b/src/Dynabook-SmalltalkCI/SdScriptFunctionCall.class.st deleted file mode 100644 index e27c5fe..0000000 --- a/src/Dynabook-SmalltalkCI/SdScriptFunctionCall.class.st +++ /dev/null @@ -1,155 +0,0 @@ -Class { - #name : #SdScriptFunctionCall, - #superclass : #Object, - #instVars : [ - 'functionName', - 'arguments', - 'script', - 'stubMap', - 'stubScript' - ], - #category : #'Dynabook-SmalltalkCI' -} - -{ #category : #accessing } -SdScriptFunctionCall class >> example [ - - - | scriptFile | - scriptFile := Tempfile withSuffix: '.sh'. - scriptFile writeStreamDo: [ :str | - str << 'sdPrettyPrint() { - local arg1=$1 - echo "The answer is $arg1" -}' withUnixLineEndings ]. - - ^ self new - script: scriptFile; - functionName: 'sdPrettyPrint'; - arguments: #('2'); - output. -] - -{ #category : #accessing } -SdScriptFunctionCall class >> exampleStub [ - - - | scriptFile result | - scriptFile := Tempfile withSuffix: '.sh'. - scriptFile writeStreamDo: [ :str | - str << 'sdPrettyPrint() { - local arg1=$1 - echo "The answer is $arg1" -}' withUnixLineEndings ]. - - result := self new - script: scriptFile; - stub: 'sdPrettyPrint' with: 'echo "Stubbed value"'; - functionName: 'sdPrettyPrint'; - arguments: #('3'); - yourself. - - result output trimmed should equal: 'Stubbed value'. - - ^ result -] - -{ #category : #accessing } -SdScriptFunctionCall >> arguments [ - ^ arguments -] - -{ #category : #accessing } -SdScriptFunctionCall >> arguments: anObject [ - arguments := anObject -] - -{ #category : #accessing } -SdScriptFunctionCall >> commandString [ - - ^ String streamContents: [ :str | - str << 'source ' << self script suForCommand << ' && '. - - self stubMap ifNotEmpty: [ - str << 'source ' << self ensureStubScript suForCommand << ' && ' ]. - - str << self functionName surroundedByDoubleQuotes << ' ' << self arguments suForCommand ] -] - -{ #category : #accessing } -SdScriptFunctionCall >> ensureStubScript [ - - stubScript ifNil: [ stubScript := Tempfile withSuffix: 'stubs.sh' ]. - - stubScript writeStreamDo: [ :str | - self stubMap keysAndValuesDo: [ :k :v | - str << k << '() {'; lf; - << ' '; << v; lf; - << '}'; lf; lf ] ]. - - ^ stubScript -] - -{ #category : #accessing } -SdScriptFunctionCall >> functionName [ - ^ functionName -] - -{ #category : #accessing } -SdScriptFunctionCall >> functionName: anObject [ - functionName := anObject -] - -{ #category : #accessing } -SdScriptFunctionCall >> output [ - - OSSUnixSubprocess new - shellCommand: self commandString; - redirectStderr; - redirectStdout; - runAndWaitOnExitDo: [ :command :outString :errString | - command isSuccess ifFalse: [ self error: 'tesseract failed with: ' , errString ]. - ^ outString ]. -] - -{ #category : #accessing } -SdScriptFunctionCall >> script [ - ^ script -] - -{ #category : #accessing } -SdScriptFunctionCall >> script: anObject [ - script := anObject -] - -{ #category : #accessing } -SdScriptFunctionCall >> stub: fncName willReturn: aString [ - - self stubMap at: fncName put: aString -] - -{ #category : #accessing } -SdScriptFunctionCall >> stub: fncName with: aString [ - - self stubMap at: fncName put: aString -] - -{ #category : #accessing } -SdScriptFunctionCall >> stubMap [ - ^ stubMap ifNil: [ stubMap := Dictionary new ]. -] - -{ #category : #accessing } -SdScriptFunctionCall >> stubMap: anObject [ - stubMap := anObject -] - -{ #category : #accessing } -SdScriptFunctionCall >> stubScript [ - ^ stubScript -] - -{ #category : #accessing } -SdScriptFunctionCall >> stubScript: anObject [ - stubScript := anObject -] diff --git a/src/Dynabook-SmalltalkCI/SdSmalltalkCICall.class.st b/src/Dynabook-SmalltalkCI/SdSmalltalkCICall.class.st deleted file mode 100644 index bcb8492..0000000 --- a/src/Dynabook-SmalltalkCI/SdSmalltalkCICall.class.st +++ /dev/null @@ -1,38 +0,0 @@ -Class { - #name : #SdSmalltalkCICall, - #superclass : #SdScriptFunctionCall, - #category : #'Dynabook-SmalltalkCI' -} - -{ #category : #accessing } -SdSmalltalkCICall >> commandString [ - - ^ 'source "/Users/sean/Documents/Reference/Smalltalk/Repositories/smalltalkCI/helpers.sh" &&', super commandString -] - -{ #category : #accessing } -SdSmalltalkCICall >> stubIsARM: aBoolean [ - - aBoolean - ifTrue: [ self stub: 'hardware_platform' with: 'echo "arm64"' ] - ifFalse: [ self stub: 'hardware_platform' with: 'echo "x86_64"' ] -] - -{ #category : #accessing } -SdSmalltalkCICall >> stubPlatform: aString isARM: aBoolean [ - - | platformOptions | - platformOptions := #('linux' 'windows' 'mac'). - platformOptions do: [ :platform | - self - stub: 'is_', platform, '_build' - with: (aString = platform) asString ]. - - self stubIsARM: aBoolean -] - -{ #category : #accessing } -SdSmalltalkCICall >> stubRelease: aString [ - - self stub: 'gtoolkit::latest_release_version' with: 'echo "', aString, '"' -] diff --git a/src/Dynabook-SmalltalkCI/SdSmalltalkCIExamples.class.st b/src/Dynabook-SmalltalkCI/SdSmalltalkCIExamples.class.st deleted file mode 100644 index a75f7b0..0000000 --- a/src/Dynabook-SmalltalkCI/SdSmalltalkCIExamples.class.st +++ /dev/null @@ -1,227 +0,0 @@ -Class { - #name : #SdSmalltalkCIExamples, - #superclass : #Object, - #category : #'Dynabook-SmalltalkCI' -} - -{ #category : #accessing } -SdSmalltalkCIExamples class >> architectureARM [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::architecture'; - stubIsARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'aarch64' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> architectureIntel [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::architecture'; - stubIsARM: false ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'x86_64' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameLinuxARM [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubRelease: 'v0.8.2574'; - stubPlatform: 'linux' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'https://github.com/feenkcom/gtoolkit/releases/download/v0.8.2574/GlamorousToolkit-Linux-aarch64-v0.8.2574.zip' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameLinuxIntel [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubRelease: 'v0.8.2574'; - stubPlatform: 'linux' isARM: false ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'https://github.com/feenkcom/gtoolkit/releases/download/v0.8.2574/GlamorousToolkit-Linux-x86_64-v0.8.2574.zip' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameMacARM [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubRelease: 'v0.8.2574'; - stubPlatform: 'mac' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'https://github.com/feenkcom/gtoolkit/releases/download/v0.8.2574/GlamorousToolkit-MacOS-aarch64-v0.8.2574.zip' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameMacIntel [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubRelease: 'v0.8.2574'; - stubPlatform: 'mac' isARM: false ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'https://github.com/feenkcom/gtoolkit/releases/download/v0.8.2574/GlamorousToolkit-MacOS-x86_64-v0.8.2574.zip' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameWindowsARMUnsupported [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubPlatform: 'windows' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - "should error" ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> archiveFilenameWindowsIntel [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::archive_url'; - stubRelease: 'v0.8.2574'; - stubPlatform: 'windows' isARM: false ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'https://github.com/feenkcom/gtoolkit/releases/download/v0.8.2574/GlamorousToolkit-Windows-x86_64-v0.8.2574.zip' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> getReleaseVersion [ - - - ^ self - given: [ :fcn | fcn functionName: 'gtoolkit::latest_release_version' ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should beginWith: 'v0.8.' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> given: givenBlock in: file whenCalledWithArguments: aCollection then: thenBlock [ - - | call | - call := SdSmalltalkCICall new - script: file; - arguments: aCollection; - yourself. - - givenBlock value: call. - - thenBlock value: call. - - ^ call -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> given: givenBlock whenCalledWithArguments: aCollection then: thenBlock [ - self - given: givenBlock - in: self mainScript - whenCalledWithArguments: aCollection - then: thenBlock -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> gtoolkitLatestReleaseJSON [ - - ^ ZnClient new - get: 'https://api.github.com/repos/feenkcom/gtoolkit/releases/latest'; - yourself - - "Adapted from https://fabianlee.org/2021/02/16/bash-determining-latest-github-release-tag-and-version/" -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> hardwarePlatform [ - - - ^ self - given: [ :fcn | fcn functionName: 'hardware_platform' ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'arm64' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> mainScript [ - - ^ FileLocator dynabookData parent / 'Repositories'/'smalltalkCI'/'gtoolkit'/'run.sh' -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> vmPathLinux [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::vm_path'; - stubPlatform: 'linux' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'bin/GlamorousToolkit-cli' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> vmPathMac [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::vm_path'; - stubPlatform: 'mac' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'GlamorousToolkit.app/Contents/MacOS/GlamorousToolkit-cli' ] -] - -{ #category : #accessing } -SdSmalltalkCIExamples class >> vmPathWindows [ - - - ^ self - given: [ :fcn | - fcn - functionName: 'gtoolkit::vm_path'; - stubPlatform: 'windows' isARM: true ] - whenCalledWithArguments: { } - then: [ :fcn | - fcn output trimmed should equal: 'bin/GlamorousToolkit-cli.exe' ] -]