Skip to content

Commit 2f791cb

Browse files
Madman10Kalehander92
authored andcommitted
refactor(src/codetracer.nim): fix alexander's nitpicks about new lines and move startCore to backends
1 parent 8cf24bd commit 2f791cb

13 files changed

+43
-36
lines changed

src/ct/cli/help.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ proc displayHelp*: void =
66
# echo "help: TODO"
77
let process = startProcess(codetracerExe, args = @["--help"], options = {poParentStreams})
88
let code = waitForExit(process)
9-
quit(code)
9+
quit(code)

src/ct/cli/list.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ proc listCommand*(rawTarget: string, rawFormat: string) =
4646
listLocalTraces(format)
4747
of ListTarget.Remote:
4848
echo "error: unsupported currently!"
49-
# listRemoteTraces(format)
49+
# listRemoteTraces(format)

src/ct/cli/logging.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ template errorMessage*(message: string) =
44
echo message
55

66
proc notSupportedCommand*(commandName: string) =
7-
echo fmt"{commandName} not supported with this backend"
7+
echo fmt"{commandName} not supported with this backend"

src/ct/codetracer.nim

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ try:
1212
except Exception as ex:
1313
echo "Unhandled exception"
1414
echo getStackTrace(ex)
15-
error "error: unhandled " & ex.msg
15+
error "error: unhandled " & ex.msg
16+

src/ct/globals.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ let
1212
# after validation
1313
var replayInteractive* = false
1414
var electronPid*: int = -1
15-
var rrPid* = -1 # global, so it can be updated immediately on starting a process, and then used in `onInterrupt` if needed
15+
var rrPid* = -1 # global, so it can be updated immediately on starting a process, and then used in `onInterrupt` if needed

src/ct/launch/backends.nim

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import
2+
std/[strformat, strutils, osproc],
3+
../../common/[start_utils, types, trace_index],
4+
../utilities/[env],
5+
../cli/[logging],
6+
cleanup
7+
8+
proc startCore*(traceArg: string, callerPid: int, test: bool) =
9+
# start_core <trace-program-pattern> <caller-pid> [--test]
10+
let recordCore = envLoadRecordCore()
11+
var trace: Trace = nil
12+
try:
13+
let traceId = traceArg.parseInt
14+
trace = trace_index.find(traceId, test=test)
15+
except ValueError:
16+
trace = trace_index.findByProgramPattern(traceArg, test=test)
17+
except CatchableError as e:
18+
errorMessage fmt"start core loading trace error: {e.msg}"
19+
quit(1)
20+
21+
if trace.isNil:
22+
echo "error: start core: trace not found for ", traceArg
23+
quit(1)
24+
# echo trace.repr
25+
let process = startCoreProcess(traceId = trace.id, recordCore=recordCore, callerPid=callerPid, test=test)
26+
let code = waitForExit(process)
27+
discard code
28+
stopCoreProcess(process, recordCore)

src/ct/launch/cleanup.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ onSignal(SIGINT):
6363

6464
onSignal(SIGTERM):
6565
cleanup()
66-
quit(0)
66+
quit(0)

src/ct/launch/launch.nim

+3-25
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,8 @@ import
99
../globals,
1010
cleanup,
1111
electron,
12-
results
13-
14-
# TODO: QA Note: move to separate file
15-
proc startCore*(traceArg: string, callerPid: int, test: bool) =
16-
# start_core <trace-program-pattern> <caller-pid> [--test]
17-
let recordCore = envLoadRecordCore()
18-
var trace: Trace = nil
19-
try:
20-
let traceId = traceArg.parseInt
21-
trace = trace_index.find(traceId, test=test)
22-
except ValueError:
23-
trace = trace_index.findByProgramPattern(traceArg, test=test)
24-
except CatchableError as e:
25-
errorMessage fmt"start core loading trace error: {e.msg}"
26-
quit(1)
27-
28-
if trace.isNil:
29-
echo "error: start core: trace not found for ", traceArg
30-
quit(1)
31-
# echo trace.repr
32-
let process = startCoreProcess(traceId = trace.id, recordCore=recordCore, callerPid=callerPid, test=test)
33-
let code = waitForExit(process)
34-
discard code
35-
stopCoreProcess(process, recordCore)
12+
results,
13+
backends
3614

3715
proc runInitial*(conf: CodetracerConf) =
3816
# TODO should this be here?
@@ -166,4 +144,4 @@ proc runInitial*(conf: CodetracerConf) =
166144
conf.traceMetadataProgramArg, conf.traceMetadataRecordPidArg,
167145
conf.traceMetadataRecent,
168146
conf.traceMetadataRecentLimit,
169-
conf.traceMetadataTest)
147+
conf.traceMetadataTest)

src/ct/trace/metadata.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ proc traceMetadata*(
2626
let traces = trace_index.findRecentTraces(limit=recentLimit, test)
2727
echo Json.encode(traces)
2828
else:
29-
echo "null"
29+
echo "null"

src/ct/trace/replay.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ proc replay*(
4444
traceFolderArg: Option[string],
4545
interactive: bool
4646
): bool =
47-
internalReplayOrUpload(patternArg, traceIdArg, traceFolderArg, interactive, command=StartupCommand.replay)
47+
internalReplayOrUpload(patternArg, traceIdArg, traceFolderArg, interactive, command=StartupCommand.replay)

src/ct/trace/run.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ proc run*(programArg: string, args: seq[string]) =
6767
recordCore=recordCore,
6868
lang=lang,
6969
recordArgs=recordArgs
70-
)
70+
)

src/ct/trace/storage_and_import.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ proc importDbTrace*(
159159

160160
proc uploadTrace*(trace: Trace) =
161161
echo "error: uploading traces not supported currently!"
162-
quit(1)
162+
quit(1)

src/ct/utilities/git.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ proc getGitTopLevel*(dir: string): string =
1414
if exitCode == 0 and output.len > 0:
1515
return output
1616
except:
17-
return ""
17+
return ""

0 commit comments

Comments
 (0)