Browse Source

Merge pull request #140 from seriyps/travis-fix

Fix travis builds; make tests more portable between PG versions
Sergey Prokhorov 7 years ago
parent
commit
ec55b9b569
4 changed files with 23 additions and 18 deletions
  1. 6 4
      .travis.yml
  2. 1 1
      Makefile
  3. 5 5
      test/epgsql_SUITE.erl
  4. 11 8
      test/epgsql_cth.erl

+ 6 - 4
.travis.yml

@@ -1,12 +1,14 @@
 addons:
-  postgresql: "9.4"
+  postgresql: "9.6"
+  apt:
+    packages:
+      - postgresql-9.6-postgis-2.3
+      - postgresql-contrib-9.6
 before_script:
-  - sudo apt-get update -qq
-  - sudo apt-get install postgresql-9.4-postgis-2.1 postgresql-contrib-9.4
   - wget https://s3.amazonaws.com/rebar3/rebar3
   - chmod u+x ./rebar3
 env:
-  - PATH=".:$PATH"
+  - PATH=".:/usr/lib/postgresql/9.6/bin:$PATH"
 install: "true"
 language: erlang
 otp_release:

+ 1 - 1
Makefile

@@ -12,7 +12,7 @@ src/epgsql_errcodes.erl:
 	./generate_errcodes_src.sh > src/epgsql_errcodes.erl
 
 test: compile
-	@$(REBAR) do ct
+	@$(REBAR) do ct -v
 
 dialyzer: compile
 	@$(REBAR) dialyzer

+ 5 - 5
test/epgsql_SUITE.erl

@@ -154,7 +154,7 @@ end_per_group(_GroupName, _Config) ->
         message = <<"canceling statement due to statement timeout">>,
         extra = [{file, <<"postgres.c">>},
                  {line, _},
-                 {routine, _}]
+                 {routine, _} | _]
         }}).
 
 %% From uuid.erl in http://gitorious.org/avtobiff/erlang-uuid
@@ -434,7 +434,7 @@ parse_error(Config) ->
     Module = ?config(module, Config),
     epgsql_ct:with_connection(Config, fun(C) ->
         {error, #error{
-            extra = [{file, _}, {line, _}, {position, <<"8">>}, {routine, _}]
+            extra = [{file, _}, {line, _}, {position, <<"8">>}, {routine, _} | _]
         }} = Module:parse(C, "select _ from test_table1"),
         {ok, S} = Module:parse(C, "select * from test_table1"),
         [#column{name = <<"id">>}, #column{name = <<"value">>}] = S#statement.columns,
@@ -507,8 +507,8 @@ execute_error(Config) ->
                   {file, _},
                   {line, _},
                   {routine, _},
-                  {schema_name, <<"public">>},
-                  {table_name, <<"test_table1">>}
+                  {schema_name, <<"public">>} | _%,
+                  %{table_name, <<"test_table1">>}
               ]
           }} = Module:execute(C, S, 0),
           {error, sync_required} = Module:bind(C, S, [3, <<"quux">>]),
@@ -914,7 +914,7 @@ warning_notice(Config) ->
         [{ok, _, _}, _] = Module:squery(C, Q),
         receive
             {epgsql, C, {notice, #error{message = <<"oops">>, extra = Extra}}} ->
-                ?assertMatch([{file, _},{line, _},{routine, _}], Extra),
+                ?assertMatch([{file, _},{line, _},{routine, _} | _], Extra),
                 ok
         after
             100 -> erlang:error(didnt_receive_notice)

+ 11 - 8
test/epgsql_cth.erl

@@ -13,7 +13,7 @@ init(_Id, State) ->
     Start = os:timestamp(),
     PgConfig = start_postgres(),
     ok = create_testdbs(PgConfig),
-    error_logger:info_msg("postgres started in ~p ms\n",
+    ct:pal(info, "postgres started in ~p ms\n",
         [timer:now_diff(os:timestamp(), Start) / 1000]),
     [{pg_config, PgConfig}|State].
 
@@ -71,7 +71,7 @@ find_utils(State) ->
             false ->
                 case filelib:wildcard("/usr/lib/postgresql/**/bin/" ++ UList) of
                     [] ->
-                        error_logger:error_msg("~s not found", [U]),
+                        ct:pal(error, "~s not found", [U]),
                         throw({util_no_found, U});
                     List -> lists:last(lists:sort(List))
                 end;
@@ -89,15 +89,18 @@ start_postgresql(Config) ->
     PgHost = "localhost",
     PgPort = get_free_port(),
     SocketDir = "/tmp",
+    Command = lists:concat(
+                [Postgres,
+                 " -k ", SocketDir,
+                 " -D ", PgDataDir,
+                 " -h ", PgHost,
+                 " -p ", PgPort]),
+    ct:pal(info, ?HI_IMPORTANCE, "Starting Postgresql: `~s`", [Command]),
     Pid = proc_lib:spawn(fun() ->
-        {ok, _, I} = exec:run_link(lists:concat([Postgres,
-            " -k ", SocketDir,
-            " -D ", PgDataDir,
-            " -h ", PgHost,
-            " -p ", PgPort]),
+        {ok, _, I} = exec:run_link(Command,
             [{stderr,
               fun(_, _, Msg) ->
-                  error_logger:info_msg("postgres: ~s", [Msg])
+                  ct:pal(info, "postgres: ~s", [Msg])
               end}]),
         loop(I)
     end),