Skip to content

Implement createCoverInstance for SqliteCovergroup#34

Merged
mballance merged 3 commits into
masterfrom
copilot/implement-create-cover-instance
Feb 12, 2026
Merged

Implement createCoverInstance for SqliteCovergroup#34
mballance merged 3 commits into
masterfrom
copilot/implement-create-cover-instance

Conversation

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

SqliteCovergroup did not implement createCoverInstance(), causing NotImplementedError when DbMerger attempts to merge covergroup instances into SQLite databases. This blocked both pyucis merge and pyucis convert operations targeting SQLite.

Changes

  • Added createCoverInstance() to SqliteCovergroup: Creates a COVERINSTANCE scope and returns a SqliteCovergroup instance, following the same pattern as MemCovergroup
def createCoverInstance(self, name: str, srcinfo: SourceInfo, weight: int,
                      source: SourceT) -> 'Covergroup':
    scope = self.createScope(name, srcinfo, weight, source,
                            ScopeTypeT.COVERINSTANCE, 0)
    return SqliteCovergroup(self.ucis_db, scope.scope_id)
  • Test coverage: Added comprehensive tests for basic instance creation, multiple instances, instances with coverpoints, and DbMerger integration
Original prompt

This section details on the original issue you should resolve

<issue_title>createCoverInstance not implemented on SQLite covergroup</issue_title>
<issue_description>
Testcase:

#!/usr/bin/env python3
"""
Issue 2 — `createCoverInstance` not implemented on SQLite covergroup.

The generic `DbMerger` calls `dst_cg.createCoverInstance(...)` when merging
covergroup data into the destination database.  The `SqliteCovergroup` class
does not override the base-class stub, which raises:

    NotImplementedError

This prevents `pyucis convert` and `pyucis merge` from writing to SQLite
via the standard merger pipeline.

Reproduce:
    python tests/test_issue2_create_cover_instance.py

Expected:  Merge into a SqliteUCIS succeeds via DbMerger.
Actual:    NotImplementedError is raised during merge.
"""

import os
import sys
import tempfile
import traceback


def create_sample_mem_db():
    """Return a MemUCIS via XML roundtrip so it has cover-instance structure."""
    from ucis.mem.mem_ucis import MemUCIS
    from ucis.source_info import SourceInfo
    from ucis.source_t import SourceT
    from ucis.scope_type_t import ScopeTypeT
    from ucis.cover_data import CoverData
    from ucis.cover_type_t import CoverTypeT
    from ucis.flags_t import FlagsT
    from ucis.xml.xml_factory import XmlFactory
    import tempfile

    db = MemUCIS()
    fh = db.createFileHandle("test.sv", os.getcwd())
    si = SourceInfo(fh, 1, 0)
    du = db.createScope("tb", si, 1, SourceT.NONE, ScopeTypeT.DU_MODULE, FlagsT(
    inst = db.createInstance("tb", si, 1, SourceT.NONE,
                            ScopeTypeT.INSTANCE, du, FlagsT(0))
    cg = inst.createCovergroup("cg", si, 1, SourceT.NONE)
    cp = cg.createScope("cp", si, 1, SourceT.NONE, ScopeTypeT.COVERPOINT, FlagsT
    cd = CoverData(CoverTypeT.CVGBIN, 0)
    cd.data = 42
    cd.goal = 1
    cp.createNextCover("bin0", cd, si)

    # Roundtrip through XML so the reader creates COVERINSTANCE scopes,
    # which is the structure DbMerger expects.
    with tempfile.NamedTemporaryFile(suffix=".xml", delete=False) as f:
        xml_path = f.name
    XmlFactory.write(db, xml_path)
    roundtripped = XmlFactory.read(xml_path)
    os.remove(xml_path)
    return roundtripped

def test_dbmerger_into_sqlite():
    """DbMerger.merge(SqliteUCIS, [MemUCIS]) should work."""
    from ucis.sqlite.sqlite_ucis import SqliteUCIS
    from ucis.merge.db_merger import DbMerger

    src = create_sample_mem_db()

    with tempfile.NamedTemporaryFile(suffix=".ucisdb", delete=False) as f:
        dst_path = f.name

    try:
        dst = SqliteUCIS(dst_path)
        merger = DbMerger()
        merger.merge(dst, [src])
        dst.close()
        print("PASS — DbMerger into SqliteUCIS succeeded")
        return True
    except NotImplementedError:
        print("FAIL — Issue 2 reproduced:")
        traceback.print_exc()
        return False
    finally:
        if os.path.exists(dst_path):
            os.remove(dst_path)


if __name__ == "__main__":
    ok = test_dbmerger_into_sqlite()
    sys.exit(0 if ok else 1)


```</issue_description>

<agent_instructions>Create a unit test that shows this issue. Investigate and correct</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Feb 12, 2026
Copilot AI and others added 2 commits February 12, 2026 20:44
Co-authored-by: mballance <1340805+mballance@users.noreply.github.com>
…cate import

Co-authored-by: mballance <1340805+mballance@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement createCoverInstance on SQLite covergroup Implement createCoverInstance for SqliteCovergroup Feb 12, 2026
Copilot AI requested a review from mballance February 12, 2026 20:48
@mballance
mballance merged commit 5f18403 into master Feb 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant