Skip to content

Commit

Permalink
Cleanup, added dev-test configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Bilenko authored and Anatoliy Bilenko committed Feb 26, 2024
1 parent 2a1b1a4 commit 88e54cc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHELL := /bin/bash
SHELL:=/bin/bash

.PHONY: test
test: clean
Expand All @@ -12,3 +12,14 @@ test: clean
.PHONY: clean
clean:
./system-test clean


.PHONY: dev-test
dev-test: dev-clean
python3 -m chronoscope create -t test/trace.txt -c test/chronoscope.yaml
./test/browse chronoscope.db ' '

.PHONY: dev-clean
dev-clean:
rm -fv chronoscope.db
rm -fv tree_111_*.png
39 changes: 23 additions & 16 deletions chronoscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import chronoscope.tree as tree
import chronoscope.chart as chart
import argparse
import errno
import sys

__version__ = '0.0.1'
Expand Down Expand Up @@ -46,21 +47,27 @@ def parse_args():


def main() -> int:
args = parse_args()

match args.command:
case "create":
db.open(args.db, db_options, create=True)
db.load(parser.parser(args.conf), args.trace)
db.mkidx()
db.close()

case "chart":
db.open(args.db, db_options)
chart.plot(args.tick_id, args.fig_size, args.depth)

case "tree":
db.open(args.db, db_options)
tree.plot(args.tick_id, args.depth)
try:
args = parse_args()
match args.command:
case "create":
db.open(args.db, db_options, create=True)
db.load(parser.parser(args.conf), args.trace)
db.mkidx()
db.close()
case "chart":
db.open(args.db, db_options)
chart.plot(args.tick_id, args.fig_size, args.depth)
case "tree":
db.open(args.db, db_options)
tree.plot(args.tick_id, args.depth)
except KeyboardInterrupt:
return errno.EINTR
except FileExistsError as e:
print(e, file=sys.stderr)
return errno.EEXIST
except FileNotFoundError as e:
print(e, file=sys.stderr)
return errno.EACCES

return 0
4 changes: 2 additions & 2 deletions chronoscope/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class Meta:

def open(path: str, opts: None | dict[str, int | str] = None, create=False):
if create and os.path.exists(path):
raise FileExistsError("`{path}' exists!")
raise FileExistsError(f"`{path}' exists!")
if not create and not os.path.exists(path):
raise FileNotFoundError("`{path}' not found!")
raise FileNotFoundError(f"`{path}' not found!")

db.init(path, opts)
db.connect()
Expand Down
11 changes: 9 additions & 2 deletions test/browse
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ set -e

DB="$1"
RQ=$(echo 'select DISTINCT(id) from tick where type="conn";' | sqlite3 $DB)
ENV=${2:-./env}

env() {
$ENV "$@"
}

for r in $RQ; do
./env chronoscope -d $DB tree -k $r
./env chronoscope -d $DB chart -k $r
# env ./env chronoscope -d $DB tree -k $r
# env ./env chronoscope -d $DB chart -k $r
env python3 -m chronoscope -d $DB tree -k $r
env python3 -m chronoscope -d $DB chart -k $r
done

0 comments on commit 88e54cc

Please sign in to comment.