您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

53 行
1.8 KiB

  1. -module(rebar_opts_parser_SUITE).
  2. -export([all/0, init_per_testcase/2]).
  3. -export([bad_arg_to_flag/1, missing_arg_to_flag/1]).
  4. -include_lib("common_test/include/ct.hrl").
  5. all() -> [bad_arg_to_flag, missing_arg_to_flag].
  6. init_per_testcase(_, Config) ->
  7. rebar_test_utils:init_rebar_state(Config, "opts_parser_").
  8. bad_arg_to_flag(Config) ->
  9. ok = meck:new(getopt),
  10. ok = meck:expect(getopt,
  11. parse,
  12. fun(_, _) -> {error, {invalid_option_arg, {foo, "null"}}} end),
  13. AppDir = ?config(apps, Config),
  14. Name = rebar_test_utils:create_random_name("bad_arg_"),
  15. Vsn = rebar_test_utils:create_random_vsn(),
  16. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  17. {error, Error} = rebar_test_utils:run_and_check(Config,
  18. [],
  19. ["compile", "--foo=null"],
  20. return),
  21. true = meck:validate(getopt),
  22. ok = meck:unload(getopt),
  23. "Invalid argument null to option foo" = lists:flatten(Error).
  24. missing_arg_to_flag(Config) ->
  25. ok = meck:new(getopt),
  26. ok = meck:expect(getopt, parse, fun(_, _) -> {error, {missing_option_arg, foo}} end),
  27. AppDir = ?config(apps, Config),
  28. Name = rebar_test_utils:create_random_name("missing_arg_"),
  29. Vsn = rebar_test_utils:create_random_vsn(),
  30. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  31. {error, Error} = rebar_test_utils:run_and_check(Config,
  32. [],
  33. ["compile", "--foo"],
  34. return),
  35. true = meck:validate(getopt),
  36. ok = meck:unload(getopt),
  37. "Missing argument to option foo" = lists:flatten(Error).