Skip to content

Commit

Permalink
test: match test minimal keys to chalk collect
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Feb 27, 2025
1 parent 96f9044 commit 1614cfd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
24 changes: 11 additions & 13 deletions src/collect.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ proc registerKeys(templ: string) =
if useOpt.isSome() and useOpt.get():
subscribedKeys[name] = true

proc registerOutconfKeys() =
# We always subscribe to _VALIDATED, even if they don't want to
# report it; they might subscribe to the error logs it generates.
#
# This basically ends up forcing getRunTimeArtifactInfo() to run in
# the system plugin.
#
# TODO: The config should hand us a list of keys to force.
subscribedKeys["_VALIDATED"] = true
registerKeys(getMarkTemplate())
registerKeys(getReportTemplate())

proc collectChalkTimeHostInfo*() =
if hostCollectionSuspended():
return
Expand Down Expand Up @@ -120,7 +108,17 @@ proc initCollection*(collectHost = true) =
"METADATA_ID",
"HASH",
])
registerOutconfKeys()

# We always subscribe to _VALIDATED, even if they don't want to
# report it; they might subscribe to the error logs it generates.
#
# This basically ends up forcing getRunTimeArtifactInfo() to run in
# the system plugin.
#
# TODO: The config should hand us a list of keys to force.
subscribedKeys["_VALIDATED"] = true
registerKeys(getMarkTemplate())
registerKeys(getReportTemplate())

# Next, register for any custom reports.
for name in getChalkSubsections("custom_report"):
Expand Down
25 changes: 5 additions & 20 deletions src/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ proc getReportTemplate*(spec = ""): string =
tmplName = attrGetOpt[string](ns & ".report_template").get("null")
return "report_template." & tmplName

template forceReportKeys*(keynames: openarray[string]) =
let templateRef = getReportTemplate()
proc forceKeys(keynames: openarray[string], templateRef: string) =
let section = templateRef & ".key"

# Create the "key" section if required.
Expand All @@ -93,25 +92,11 @@ template forceReportKeys*(keynames: openarray[string]) =
Con4mType(kind: TypeBool),
)

proc forceChalkKeys*(keynames: openarray[string]) =
let templateRef = getMarkTemplate()
let section = templateRef & ".key"
proc forceReportKeys*(keynames: openarray[string]) =
forceKeys(keynames, getReportTemplate())

# Create the "key" section if required.
if not sectionExists(section) and keynames.len > 0:
con4mSectionCreate(section)

let keys = attrGetObject(section).getContents()

for item in keynames:
# Create the item section if required.
if item notin keys:
con4mSectionCreate(section & "." & item)
con4mAttrSet(
section & "." & item & ".use",
pack(true),
Con4mType(kind: TypeBool),
)
proc forceChalkKeys*(keynames: openarray[string]) =
forceKeys(keynames, getMarkTemplate())

proc runCallback*(cb: CallbackObj, args: seq[Box]): Option[Box] =
return con4mRuntime.configState.sCall(cb, args)
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ def test_profiles(
"CHALK_ID",
"CHALK_VERSION",
"METADATA_ID",
"HASH",
}
for key in minimal_chalk:
assert key in chalk_mark
Expand Down

0 comments on commit 1614cfd

Please sign in to comment.