Skip to content
This repository

Support ct_run using short name #230

Merged
merged 1 commit into from almost 2 years ago

3 participants

Tim Watson Luc Tanguay Dave Smith
Tim Watson

Not every system under test can be run with long names, and this makes
rebar's common_test support useless in those environments, as it
currently uses long names (test@hostname.domain) by default, without
recourse to change them.

This patch adds support for a {ct_use_short_names, boolean()} config
variable, which allows the user to specify whether short or long names
are required.

Tim Watson Support ct_run using short name
Not every system under test can be run with long names, and this makes
rebar's common_test support useless in those environments, as it
currently uses long names (test@hostname.domain) by default, without
recourse to change them.

This patch adds support for a {ct_use_short_names, boolean()} config
variable, which allows the user to specify whether short or long names
are required.
bebd9d2
Dave Smith dizzyd merged commit 9ec6f37 into from June 08, 2012
Dave Smith dizzyd closed this June 08, 2012
Luc Tanguay

Still have a problem for me (on Window$). rebar_ct:build_name/1 returns
" -name test@" net_adm:localhost()
when long names are used. But on my system localhost gives short hostname without FQDN. I fixed it for me by simply returning " -name test" when long name are requested and rebuilt rebar.
NOTE: I'm using CT and Mnesia and remote client querying Mnesia. So every body must use the same type of names.

Tim Watson

Hmn, that is one possibility. I have run into numerous problems with longnames when trying to detect FQDN in a realistic cross platform manner, so I generally try to use short names for testing, but I can understand that this won't work for everyone.

However, as you can from the diffs above, I didn't actually change the longnames handling in rebar_ct here, but simply made it possible to use a shortname instead, so if the default longnames handling isn't working for you, perhaps an alternative pull request would be a good idea. Bare in mind any changes will need to be verified as working on as many supported platforms as possible though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 22, 2012
Tim Watson Support ct_run using short name
Not every system under test can be run with long names, and this makes
rebar's common_test support useless in those environments, as it
currently uses long names (test@hostname.domain) by default, without
recourse to change them.

This patch adds support for a {ct_use_short_names, boolean()} config
variable, which allows the user to specify whether short or long names
are required.
bebd9d2
This page is out of date. Refresh to see the latest.
3  rebar.config.sample
@@ -85,6 +85,9 @@
85 85
 %% Option to pass extra parameters when launching Common Test
86 86
 {ct_extra_params, "-boot start_sasl -s myapp"}.
87 87
 
  88
+%% Option to use short names (i.e., -sname test) when starting ct
  89
+{ct_use_short_names, true}.
  90
+
88 91
 %% == Cleanup ==
89 92
 
90 93
 %% Which files to cleanup
14  src/rebar_ct.erl
@@ -145,14 +145,14 @@ make_cmd(TestDir, Config) ->
145 145
               undefined ->
146 146
                   ?FMT("erl " % should we expand ERL_PATH?
147 147
                        " -noshell -pa ~s ~s"
148  
-                       " -name test@~s"
  148
+                       " ~s"
149 149
                        " -logdir \"~s\""
150 150
                        " -env TEST_DIR \"~s\""
151 151
                        " ~s"
152 152
                        " -s ct_run script_start -s erlang halt",
153 153
                        [CodePathString,
154 154
                         Include,
155  
-                        net_adm:localhost(),
  155
+                        build_name(Config),
156 156
                         LogDir,
157 157
                         filename:join(Cwd, TestDir),
158 158
                         get_extra_params(Config)]) ++
@@ -164,14 +164,14 @@ make_cmd(TestDir, Config) ->
164 164
               SpecFlags ->
165 165
                   ?FMT("erl " % should we expand ERL_PATH?
166 166
                        " -noshell -pa ~s ~s"
167  
-                       " -name test@~s"
  167
+                       " ~s"
168 168
                        " -logdir \"~s\""
169 169
                        " -env TEST_DIR \"~s\""
170 170
                        " ~s"
171 171
                        " -s ct_run script_start -s erlang halt",
172 172
                        [CodePathString,
173 173
                         Include,
174  
-                        net_adm:localhost(),
  174
+                        build_name(Config),
175 175
                         LogDir,
176 176
                         filename:join(Cwd, TestDir),
177 177
                         get_extra_params(Config)]) ++
@@ -180,6 +180,12 @@ make_cmd(TestDir, Config) ->
180 180
     RawLog = filename:join(LogDir, "raw.log"),
181 181
     {Cmd, RawLog}.
182 182
 
  183
+build_name(Config) ->
  184
+    case rebar_config:get_local(Config, ct_use_short_names, false) of
  185
+        true -> "-sname test";
  186
+        false -> " -name test@" ++ net_adm:localhost()
  187
+    end.
  188
+
183 189
 get_extra_params(Config) ->
184 190
     rebar_config:get_local(Config, ct_extra_params, "").
185 191
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.