Skip to content

Commit

Permalink
Issue #4: basic eval is pretty much working ... play around with a fe…
Browse files Browse the repository at this point in the history
…w more commands, before addressing the tODE test failures (run failing tests using --debugGem)
  • Loading branch information
dalehenrich committed Jul 28, 2023
1 parent 155731e commit 428308d
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 19 deletions.
53 changes: 43 additions & 10 deletions bin/todeIt.solo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env superdoit_solo
options
{
SuperDoitOptionalOptionWithRequiredArg long: 'file'.
SuperDoitOptionalOptionWithRequiredArg long: 'registry'.
SuperDoitOptionalOptionWithRequiredArg long: 'stoneName'.
SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'.
Expand All @@ -9,24 +10,48 @@ SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'.
Usage
-----
USAGE $basename [--help | -h] [--debug | -D] [--debugGem] [-v | --verbose] \
--registry=<registry-name> --stoneName=<stone-name> <tode-command>
[--registry=<registry-name> --stoneName=<stone-name>] \
[ <tode-command> | --file=<tode-commands-file> ]

DESCRIPTION
Execute tODE commands in the stone and print the result.
Execute tODE commands in the stone and print the result. With no --registry
and no --stoneName specified, the script must be executed in the target stone
directory.

OPTIONS
-h, --help display usage message
-D, --debug bring up topaz debugger in the event of a script error
--debugGem If terminal is connected to stdout, bring up debugger. If not,
dump stack to stdout and wait for topaz to attach using topaz
DEBUGGEM command.
--registry=<registry-name>
Name of registry used to look up stoneName.
--stoneName=<stone-name>
Name of stone to run script against.
--file=<tode-commands-file>
Name of file containing one or more tODE commands

EXAMPLES
$basename --help
$basename -D
$basename --debugGem
$basename "eval \`3+4\`"
$basename "eval \`3+4\`" --registry=issue_4 --stoneName=gs_370
# passing tests
cat - > testing << EOF
eval \`TDTestToolTests enableTests: false\`
test --batch class TDTestToolTests
eval \`self hasFailures ifTrue: [ self error: 'FAILING' ] ifFalse: [ self ]\`
EOF
$basename --file=testing
#failing tests
cat - > testing << EOF
eval \`TDTestToolTests enableTests: true\`
test --batch class TDTestToolTests
eval \`self hasFailures ifTrue: [ self error: 'FAILING' ] ifFalse: [ self ]\`
EOF
$basename --file=testing

$basename 'eval `3+4`' --registry=issue_4 --stoneName=gs_370
$basename "eval `3+4`"
-----
%
specs
Expand Down Expand Up @@ -66,16 +91,14 @@ RwLoadSpecificationV2 {
]
%
doit
| registryClass stoneSpec sessionDescription |
| registryClass stoneSpec sessionDescription commands result |
self preDoitSpecLoad: [:spec |
spec projectName = 'GsCommands'
ifTrue: [ spec projectsHome: '$GEMSTONE/examples/GsCommands/projectsHome' ]
ifFalse: [ spec projectsHome: self dirname asFileReference parent parent ] ].
registryClass := (self globalNamed: 'GDKRegistry').
self verbose
ifTrue: [ (self globalNamed: 'GDKGsDevKit_stonesBase') verbose: true ].
self positionalArgs size = 0
ifTrue: [ self error: 'a tODE command must be entered on command line' ].
self registry
ifNotNil: [:registryName |
| stonesRegistry |
Expand All @@ -89,8 +112,18 @@ doit
stoneSpec := (self globalNamed: 'GDKAbstractRegistryStore') fromPath: specFile ifAbsent: [] ].
sessionDescription := (self globalNamed: 'TDSessionDescription')
fromFile: stoneSpec todeHome asFileReference / 'sys' / 'local' / 'sessions' / stoneSpec stoneName.
^ ((self globalNamed: 'TDShell')
self positionalArgs size > 0
ifTrue: [
"workaround for https://github.com/dalehenrich/superDoit/issues/56"
commands := String new.
self positionalArgs do: [:arg | commands add: arg; add: ' ' ] ]
ifFalse: [
self file
ifNil: [ self error: 'a tODE command must be entered on command line as a positional argument or via --file option' ]
ifNotNil: [ :commandsFile |
commands := commandsFile asFileReference contents ] ].
result := ((self globalNamed: 'TDShell')
sessionDescription: sessionDescription
evaluate: (self positionalArgs at: 1)
debugMode: self debug) asString
evaluate: commands
debugMode: self debugGem) asString.
%
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
server external session calls
_serverExecuteString: executeString
_serverExecuteString: executeString debugMode: debugMode
| doitString |
doitString := '
doitString := debugMode
ifTrue: [
'
[
^ (' , executeString
,
') ]
^ (' , executeString
,
') ]
on: Error, Halt
do: [ :ex | System waitForDebug ]'.
do: [ :ex | System waitForDebug ]' ]
ifFalse: [ executeString ].
[ self session nbExecute: doitString ]
on: GsErrorNotification
do: [ :ex | self error: 'Unable to execute #executeString: on tODE server' ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ evaluateCommand: command batchMode: batchBool
^ self
_serverExecuteString:
'(' , self todeServerAccessString , ' for: ' , self shell shellId asString
, ') evaluateSTONCommand:' , stonString printString
, ') evaluateSTONCommand:' , stonString printString
debugMode: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
evaluation
evaluateCommand: command batchMode: batchBool debugMode: debugMode
| stonString |
stonString := STON toString: command.
^ self
_serverExecuteString:
'(' , self todeServerAccessString , ' for: ' , self shell shellId asString
, ') evaluateSTONCommand:' , stonString printString
debugMode: debugMode
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
instance creation
sessionDescription: sessionDescription evaluate: script
^ self sessionDescription: sessionDescription evaluate: script debugMode: true
^ self sessionDescription: sessionDescription evaluate: script debugMode: false
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ evaluate: aString batchMode: aBool
^ result ]
on: Error , TDRestoreFromBackupComplete , GsTopezCommandErrorNotification
do: [ :ex |
(ex isKindOf: GciError)
ifTrue: [
| errorMessage |
"until 50621 is fixed - just return first line of stack"
self debugMode
ifTrue: [ ex pass ].
errorMessage := 'Topez ERROR: ' , ex description readStream nextLine.
self resetStack.
^ errorMessage ].
((ex isKindOf: GsTopezCommandErrorNotification) or: [ ex isKindOf: Error ])
ifTrue: [
| errorMessage |
Expand All @@ -17,5 +26,6 @@ evaluate: aString batchMode: aBool
errorMessage := 'Topez ERROR: ' , ex description.
self resetStack.
^ errorMessage ].

self logout. "TDRestoreFromBackupComplete - logout and return restore message"
^ ex description ]
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ evaluateCommand: command batchMode: aBool
ifTrue: [ ^ '' ].
(self builtInCommands includes: command command)
ifTrue: [ ^ self executeBuiltIn: command ].
^ (self topezClient evaluateCommand: command batchMode: aBool)
^ (self topezClient evaluateCommand: command batchMode: aBool debugMode: self debugMode)
convertTDEvaluateTokenResponseToText: self objectSerializer

0 comments on commit 428308d

Please sign in to comment.