diff --git a/bin/todeIt.solo b/bin/todeIt.solo index be964d4f..060d63fb 100755 --- a/bin/todeIt.solo +++ b/bin/todeIt.solo @@ -1,6 +1,7 @@ #!/usr/bin/env superdoit_solo options { +SuperDoitOptionalOptionWithRequiredArg long: 'file'. SuperDoitOptionalOptionWithRequiredArg long: 'registry'. SuperDoitOptionalOptionWithRequiredArg long: 'stoneName'. SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'. @@ -9,10 +10,13 @@ SuperDoitOptionalOptionWithNoArg long: 'verbose' short: 'v'. Usage ----- USAGE $basename [--help | -h] [--debug | -D] [--debugGem] [-v | --verbose] \ - --registry= --stoneName= + [--registry= --stoneName=] \ + [ | --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 @@ -20,13 +24,34 @@ OPTIONS --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= + Name of registry used to look up stoneName. + --stoneName= + Name of stone to run script against. + --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 @@ -66,7 +91,7 @@ RwLoadSpecificationV2 { ] % doit - | registryClass stoneSpec sessionDescription | + | registryClass stoneSpec sessionDescription commands result | self preDoitSpecLoad: [:spec | spec projectName = 'GsCommands' ifTrue: [ spec projectsHome: '$GEMSTONE/examples/GsCommands/projectsHome' ] @@ -74,8 +99,6 @@ doit 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 | @@ -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. % diff --git a/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString..st b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString.debugMode..st similarity index 53% rename from src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString..st rename to src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString.debugMode..st index a596d47a..5d90a853 100644 --- a/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString..st +++ b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/_serverExecuteString.debugMode..st @@ -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' ]. diff --git a/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode..st b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode..st index dfe69c28..027ac9fe 100644 --- a/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode..st +++ b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode..st @@ -5,4 +5,5 @@ evaluateCommand: command batchMode: batchBool ^ self _serverExecuteString: '(' , self todeServerAccessString , ' for: ' , self shell shellId asString - , ') evaluateSTONCommand:' , stonString printString \ No newline at end of file + , ') evaluateSTONCommand:' , stonString printString + debugMode: false \ No newline at end of file diff --git a/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode.debugMode..st b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode.debugMode..st new file mode 100644 index 00000000..3ae54edb --- /dev/null +++ b/src/GsDevKit_stones-Tode.package/TDExternalSessionClient.class/instance/evaluateCommand.batchMode.debugMode..st @@ -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 \ No newline at end of file diff --git a/src/GsDevKit_stones-Tode.package/TDShell.class/class/sessionDescription.evaluate..st b/src/GsDevKit_stones-Tode.package/TDShell.class/class/sessionDescription.evaluate..st index 4bd63840..e0291026 100644 --- a/src/GsDevKit_stones-Tode.package/TDShell.class/class/sessionDescription.evaluate..st +++ b/src/GsDevKit_stones-Tode.package/TDShell.class/class/sessionDescription.evaluate..st @@ -1,3 +1,3 @@ instance creation sessionDescription: sessionDescription evaluate: script - ^ self sessionDescription: sessionDescription evaluate: script debugMode: true \ No newline at end of file + ^ self sessionDescription: sessionDescription evaluate: script debugMode: false \ No newline at end of file diff --git a/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluate.batchMode..st b/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluate.batchMode..st index 280bb0af..d33ab801 100644 --- a/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluate.batchMode..st +++ b/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluate.batchMode..st @@ -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 | @@ -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 ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluateCommand.batchMode..st b/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluateCommand.batchMode..st index 83f2cfeb..d845e2bd 100644 --- a/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluateCommand.batchMode..st +++ b/src/GsDevKit_stones-Tode.package/TDShell.class/instance/evaluateCommand.batchMode..st @@ -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 \ No newline at end of file