檢視原始碼 ct_run

用於從作業系統命令列啟動 Common Test 的程式。

說明

ct_run 程式會隨著 Erlang/OTP 和 Common Test 應用程式自動安裝(如需更多資訊,請參閱使用者指南中的安裝章節)。此程式接受不同的啟動旗標。某些旗標會觸發 ct_run 啟動 Common Test 並將資料傳遞給它。某些旗標會啟動一個 Erlang 節點,該節點已準備好在特定模式下執行 Common Test

ct_run 程式對應的介面函式 ct:run_test/1 用於從 Erlang shell (或 Erlang 程式) 啟動 Common Test。詳細資訊請參閱 ct 手冊頁面。

ct_run 也接受 Erlang 模擬器旗標。這些旗標在 ct_run 呼叫 erl 以啟動 Erlang 節點時使用(這使得可以將目錄新增至程式碼伺服器路徑、變更節點上的 cookie、啟動更多應用程式等等)。

使用可選旗標 -erl_argsct_run 命令列上的選項可以分為兩組:

  • 一組是讓 Common Test 處理的選項(那些在 -erl_args 之前的選項)。
  • 一組是讓 Common Test 忽略並直接傳遞給模擬器的選項(那些在 -erl_args 之後的選項)。

-erl_args 之前的選項中,Common Test 無法識別的選項也會原封不動地傳遞給模擬器。使用者可以透過 -erl_argsct_run 命令列上指定具有相同名稱但目的地不同的旗標。

如果在選項的 Common Test 群組(在 -erl_args 之前)中指定了旗標 -pa-pz,則相對目錄會被轉換為絕對目錄,並由 Common Test 重新插入程式碼路徑中。這是為了避免在 Common Test 在測試執行期間變更工作目錄時載入使用者模組時發生問題。但是,Common Test 會忽略命令列上 -erl_args 之後的旗標 -pa-pz。這些目錄會正常新增至程式碼路徑(即,以指定的格式)。

程式結束前會設定結束狀態。值 0 表示測試結果成功,1 表示有一個或多個測試案例失敗或自動跳過,而 2 表示測試執行失敗。

如果呼叫 ct_run 時使用選項 -help,它會將所有有效的啟動旗標列印到 stdout

從命令列執行測試

 ct_run -dir TestDir1 TestDir2 .. TestDirN |
  [-dir TestDir] -suite Suite1 Suite2 .. SuiteN
  [-group Groups1 Groups2 .. GroupsN] [-case Case1 Case2 .. CaseN]
  [-step [config | keep_inactive]]
  [-config ConfigFile1 ConfigFile2 .. ConfigFileN]
  [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
   ConfigString2 and .. CallbackModuleN ConfigStringN]
  [-decrypt_key Key] | [-decrypt_file KeyFile]
  [-label Label]
  [-logdir LogDir]
  [-logopts LogOpts]
  [-verbosity GenVLevel | [Category1 VLevel1 and
   Category2 VLevel2 and .. CategoryN VLevelN]]
  [-silent_connections [ConnType1 ConnType2 .. ConnTypeN]]
  [-stylesheet CSSFile]
  [-cover CoverCfgFile]
  [-cover_stop Bool]
  [-event_handler EvHandler1 EvHandler2 .. EvHandlerN] |
  [-event_handler_init EvHandler1 InitArg1 and
   EvHandler2 InitArg2 and .. EvHandlerN InitArgN]
  [-include InclDir1 InclDir2 .. InclDirN]
  [-no_auto_compile]
  [-abort_if_missing_suites]
  [-multiply_timetraps Multiplier]
  [-scale_timetraps]
  [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc]
  [-repeat N] |
  [-duration HHMMSS [-force_stop [skip_rest]]] |
  [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]]
  [-basic_html]
  [-no_esc_chars]
  [-keep_logs all | NLogs]
  [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and ..
   CTHModuleN CTHOptsN]
  [-ct_hooks_order test | config]
  [-exit_status ignore_config]
  [-help]

使用測試規範執行測試

 ct_run -spec TestSpec1 TestSpec2 .. TestSpecN
  [-join_specs]
  [-config ConfigFile1 ConfigFile2 .. ConfigFileN]
  [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
   ConfigString2 and .. and CallbackModuleN ConfigStringN]
  [-decrypt_key Key] | [-decrypt_file KeyFile]
  [-label Label]
  [-logdir LogDir]
  [-logopts LogOpts]
  [-verbosity GenVLevel | [Category1 VLevel1 and
   Category2 VLevel2 and .. CategoryN VLevelN]]
  [-allow_user_terms]
  [-silent_connections [ConnType1 ConnType2 .. ConnTypeN]]
  [-stylesheet CSSFile]
  [-cover CoverCfgFile]
  [-cover_stop Bool]
  [-event_handler EvHandler1 EvHandler2 .. EvHandlerN] |
  [-event_handler_init EvHandler1 InitArg1 and
   EvHandler2 InitArg2 and .. EvHandlerN InitArgN]
  [-include InclDir1 InclDir2 .. InclDirN]
  [-no_auto_compile]
  [-abort_if_missing_suites]
  [-multiply_timetraps Multiplier]
  [-scale_timetraps]
  [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc]
  [-repeat N] |
  [-duration HHMMSS [-force_stop [skip_rest]]] |
  [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]]
  [-basic_html]
  [-no_esc_chars]
  [-keep_logs all | NLogs]
  [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and ..
   CTHModuleN CTHOptsN]
  [-ct_hooks_order test | config]
  [-exit_status ignore_config]

重新整理 HTML 索引檔案

 ct_run -refresh_logs [-logdir LogDir] [-basic_html]
  [-keep_logs all | NLogs]

以互動模式執行 Common Test

 ct_run -shell
  [-config ConfigFile1 ConfigFile2 ... ConfigFileN]
  [-userconfig CallbackModule1 ConfigString1 and CallbackModule2
   ConfigString2 and .. and CallbackModuleN ConfigStringN]
  [-decrypt_key Key] | [-decrypt_file KeyFile]

啟動 Common Test 主節點

 ct_run -ctmaster

另請參閱

有關啟動旗標的資訊,請參閱使用者指南中的執行測試和分析結果章節。