Skip to content

Commit

Permalink
test: compile support tests
Browse files Browse the repository at this point in the history
Files messages.exs and random_init.exs become messages.ex and random_init.ex (note the missing trailing 's')
  • Loading branch information
ahamez committed Oct 4, 2024
1 parent 242d97c commit 9e79bde
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Protox.Mixfile do

# Do not compile conformance and benchmarks related files when in production
defp elixirc_paths(:prod), do: ["lib"]
defp elixirc_paths(_), do: ["lib", "conformance", "benchmarks"]
defp elixirc_paths(_), do: ["lib", "conformance", "benchmarks", "test/support"]

def application do
[
Expand Down
5 changes: 0 additions & 5 deletions test/protox/decode_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# A dedicated module to make sure all messages are compiled before Protox.DecodeTest.
defmodule Protox.DecodeTestMessages do
Code.require_file("./test/support/messages.exs")
end

defmodule Protox.DecodeTest do
use ExUnit.Case

Expand Down
2 changes: 0 additions & 2 deletions test/protox/encode_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
defmodule Protox.EncodeTest do
use ExUnit.Case

Code.require_file("./test/support/messages.exs")

test "Empty" do
assert %Sub{} |> Protox.encode!() |> :binary.list_to_bin() == <<>>
end
Expand Down
2 changes: 0 additions & 2 deletions test/protox/generate_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
defmodule Protox.GenerateTest do
use ExUnit.Case

Code.require_file("./test/support/messages.exs")

test "Generate code in a single file" do
file = Path.join(__DIR__, "../samples/prefix/bar/bar.proto")
generated_file_name = "generated_code.ex"
Expand Down
5 changes: 0 additions & 5 deletions test/protox/json_decode_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# A dedicated module to make sure all messages are compiled before Protox.JsonDecodeTest.
defmodule Protox.JsonDecodeTestMessages do
Code.require_file("./test/support/messages.exs")
end

defmodule Protox.JsonDecodeTest do
use ExUnit.Case
use Protox.Float
Expand Down
4 changes: 0 additions & 4 deletions test/protox/json_encode_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
defmodule Protox.JsonEncodeTestMessages do
Code.require_file("./test/support/messages.exs")
end

defmodule Protox.JsonEncodeTest do
use ExUnit.Case, async: false
use Protox.Float
Expand Down
2 changes: 0 additions & 2 deletions test/protox/merge_message_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
defmodule Protox.MergeMessageTest do
use ExUnit.Case

Code.require_file("./test/support/messages.exs")

doctest Protox.MergeMessage

test "Protobuf 2, replace only set scalar fields" do
Expand Down
3 changes: 0 additions & 3 deletions test/protox_properties_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ defmodule Protox.PropertiesTest do
use ExUnit.Case
use PropCheck

Code.require_file("test/support/messages.exs")
Code.require_file("test/support/random_init.exs")

@moduletag :slow
@moduletag timeout: 60_000 * 5

Expand Down
7 changes: 2 additions & 5 deletions test/protox_test.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
defmodule ProtoxTest do
use ExUnit.Case

Code.require_file("test/support/messages.exs")
Code.require_file("test/support/random_init.exs")

use Protox,
schema: """
syntax = "proto3";
Expand Down Expand Up @@ -342,7 +339,7 @@ defmodule ProtoxTest do
label: :optional,
name: :oneof_1_foreign_enum,
tag: 6,
type: {:enum, Abc.Def.ForeignEnum}
type: {:enum, Abc.Def.MyForeignEnum}
},
%Protox.Field{
json_name: "oneof1Proto2a",
Expand Down Expand Up @@ -575,7 +572,7 @@ defmodule ProtoxTest do
label: :optional,
name: :oneof_1_foreign_enum,
tag: 6,
type: {:enum, Namespace.Abc.Def.ForeignEnum}
type: {:enum, Namespace.Abc.Def.MyForeignEnum}
},
%Protox.Field{
json_name: "oneof1Proto2a",
Expand Down
4 changes: 2 additions & 2 deletions test/samples/proto3.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "proto2.proto";

package abc.def;

enum ForeignEnum {
enum MyForeignEnum {
option allow_alias = true;
FOREIGN_ZERO = 0;
FOREIGN_ONE = 1;
Expand All @@ -25,7 +25,7 @@ message Proto3 {
oneof oneof_1 {
int32 oneof_1_int32 = 4;
double oneof_1_double = 5;
ForeignEnum oneof_1_foreign_enum = 6;
MyForeignEnum oneof_1_foreign_enum = 6;
Proto2A oneof_1_proto2a = 7;
}

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 9e79bde

Please sign in to comment.