測試

Starlark 存取測試基礎架構的輔助方法。

會員

analysis_test

None testing.analysis_test(name, implementation, attrs=None, fragments=[], toolchains=[], attr_values={})

實驗功能。這個 API 仍在實驗階段,隨時可能變更。請勿依附於此項目。透過設定--+experimental_analysis_test_call
建立新的分析測試目標,即可以實驗為基礎啟用這個 API。

測試的遞移依附元件數量有限。這項限制是由 --analysis_testing_deps_limit 旗標控管。

參數

參數 說明
name 所需
目標名稱。應為 Starlark ID,且符合模式「[A-Za-z_][A-Za-z0-9_]*」。
implementation 必要
Starlark 函式實作此分析測試。只能包含一個參數:ctx。系統會在分析階段呼叫這個函式。它可以存取由 attrs 宣告的屬性,並透過 attr_values 填入。實作函式可能無法登錄動作。而是必須透過提供 AnalysisTestResultInfo 來註冊通過/失敗結果。
attrs dict; or None; default = None
字典宣告屬性。請參閱 rule呼叫.Attributes 屬性,使用 analysis_test_transition 定義的設定轉換。
fragments sequence of strings; default = []
用於實作分析測試的設定片段清單。
toolchains sequence; default = []
測試所需的工具鍊組合。請參閱規則呼叫說明。
attr_values dict of strings; default = {}
要傳遞至實作的屬性值字典。

ExecutionInfo

ExecutionInfo testing.ExecutionInfo(requirements={}, exec_group='test')

testing.ExecutionInfo 供應商金鑰/建構函式

TestEnvironment

RunEnvironmentInfo testing.TestEnvironment(environment, inherited_environment=[])

已淘汰:請改用 RunEnvironmentInfo。建立新的測試環境提供者。使用這個提供者指定測試執行期間可用的額外環境變數。

參數

參數 說明
environment 必要
字串鍵和值的對應,代表環境變數及其值。系統會在測試執行期間提供這些內容。
inherited_environment sequence of strings; default = []
環境變數的名稱序列。這些變數可在測試執行期間,使用從殼層環境中取得的現有值來提供。如果 environmentinherited_environment 中都包含變數,系統會優先採用從殼層環境沿用的值 (如有設定)。