Skip to content

Commit

Permalink
Minor fixes related to git and file reading. git commit sha is sent t…
Browse files Browse the repository at this point in the history
…o server with --tmnet.
  • Loading branch information
tarpas committed May 12, 2023
1 parent 598930d commit 58353c2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion testmon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PYTEST_DONT_REWRITE"""
VERSION = "2.0.7b1"
VERSION = "2.0.7a2"
21 changes: 17 additions & 4 deletions testmon/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from testmon.process_code import blob_to_checksums, checksums_to_blob


DATA_VERSION = 9
DATA_VERSION = 11

ChangedFileData = namedtuple(
"ChangedFileData", "filename name method_checksums id failed"
Expand Down Expand Up @@ -278,8 +278,13 @@ def insert_test_file_fps(self, tests_deps_n_outcomes, exec_id=None):
)
self.fetch_or_create_file_fp.cache_clear()
cursor.execute(
"DELETE FROM file_fp where id not in (select fingerprint_id from test_execution_file_fp)"
"DELETE FROM file_fp WHERE "
" id NOT IN (select fingerprint_id from test_execution_file_fp)"
)
self.refresh_suite_files_checksums(con, exec_id)

def refresh_suite_files_checksums(self, con, exec_id):
pass

def _fetch_data_version(self):
con = self.con
Expand Down Expand Up @@ -350,7 +355,7 @@ def _create_test_execution_statement(self):
CREATE INDEX test_execution_fk_name ON test_execution ({self._test_execution_fk_column()}, test_name);
CREATE TABLE temp_files_checksums (exec_id INTEGER, filename TEXT, checksum TEXT);
CREATE INDEX temp_files_checksums_mcall ON temp_files_checksums (exec_id);
CREATE INDEX temp_files_checksums_mcall ON temp_files_checksums (exec_id, filename, checksum);
CREATE TABLE temp_filenames (exec_id INTEGER, filename TEXT);
CREATE INDEX temp_filenames_eid ON temp_filenames (exec_id);
Expand All @@ -365,7 +370,7 @@ def _create_file_fp_statement(self):
method_checksums BLOB,
mtime FLOAT,
checksum TEXT,
UNIQUE (filename, method_checksums)
UNIQUE (filename, checksum,method_checksums)
);"""

def _create_test_execution_ffp_statement(
Expand All @@ -379,6 +384,14 @@ def _create_test_execution_ffp_statement(
FOREIGN KEY(fingerprint_id) REFERENCES file_fp(id)
);
CREATE INDEX test_execution_file_fp_both ON test_execution_file_fp (test_execution_id, fingerprint_id);
-- the following table stores the same data coarsely, but is used for faster queries
CREATE TABLE suite_execution_file_checksum (
suite_execution_id INTEGER,
filename TEXT,
fsha text,
FOREIGN KEY(suite_execution_id) REFERENCES suite_execution(id)
);
CREATE UNIQUE INDEX sefch_suite_id_filename_sha ON suite_execution_file_checksum(suite_execution_id, filename, fsha);
"""

def init_tables(self):
Expand Down
11 changes: 9 additions & 2 deletions testmon/process_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,16 @@ def _next_lineno(nodes, i, end):

class Module:
def __init__(
self, source_code=None, mtime=None, ext="py", fs_checksum=None, filename=None
self,
source_code=None,
mtime=None,
ext="py",
fs_checksum=None,
filename=None,
rootdir=None,
):
self.filename = filename
self.rootdir = rootdir
self._blocks = None
self.counter = 0
self.mtime = mtime
Expand Down Expand Up @@ -184,7 +191,7 @@ def blocks(self):
@property
def source_code(self):
if self._source_code is None:
self._source_code = read_source_sha(self.filename)[0]
self._source_code = read_source_sha(Path(self.rootdir) / self.filename)[0]
return self._source_code

@property
Expand Down
1 change: 1 addition & 0 deletions testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def get_file(self, filename):
ext=filename.rsplit(".", 1)[1],
fs_checksum=checksum,
filename=filename,
rootdir=self.rootdir,
)
else:
self.cache[filename] = None
Expand Down

0 comments on commit 58353c2

Please sign in to comment.