Permalink
Browse files

Improved Rake and restructured

  • Loading branch information...
freke committed Oct 31, 2010
1 parent af6b986 commit 95058086ee38d6ef038202319077eaca70a34330
View
@@ -8,4 +8,6 @@
keywords
* freke <davabe@hotmail.com>
- Fixed enum support
-
+- Changed build system to Rake
+- Added QuickCheck tests
+- Changed so parsing of proto files is done by leex and yecc
View
@@ -67,6 +67,15 @@ _pb modules. Running protobuffs_compile:scan_file/1 reads the erlang forms from
the pokemon_pb.beam file and expands and alters those forms to create the generated
module.
+## Building with Rake
+If in rake is installed run
+ > rake
+To run the tests run
+ > rake test
+QuickCheck must be installed, QuickCheck Mini is free and can be found at http://www.quviq.com/
+To make the dockumentation run
+ > rake doc
+
## CREDITS
Some of the protobuffs.erl module came from code written by Brian Buchanan.
View
@@ -10,20 +10,20 @@ PWD = `pwd`.strip
INCLUDE = "include"
ERLC_FLAGS = "-I#{INCLUDE} +warn_unused_vars +warn_unused_import"
-SRC = FileList['src/**/*.erl']
+SRC = FileList['src/**/*.erl'] + FileList['test/**/*erl']
YRL = FileList['src/**/*.yrl']
XRL = FileList['src/**/*.xrl']
OBJ = SRC.pathmap("%{src,ebin}X.beam") + YRL.pathmap("%X.beam") + XRL.pathmap("%X.beam")
-CLEAN.include(['**/*.dump','*.hrl','*.beam'])
-CLOBBER.include(['**/*.beam'] + YRL.pathmap("%X.erl") + XRL.pathmap("%X.erl"))
+CLEAN.include(['**/*.dump'])
+CLOBBER.include(['**/*.beam','test/*.hrl','doc/*'] + YRL.pathmap("%X.erl") + XRL.pathmap("%X.erl"))
directory 'ebin'
rule ".beam" => ["%{ebin,src}X.erl"] do |t|
if t.source[-14,14] == "pokemon_pb.erl"
- sh("erlc -pa ebin -W #{ERLC_FLAGS} +debug_info -o ebin #{t.source}")
+ sh("erlc -pa ebin -W #{ERLC_FLAGS} +debug_info -o #{t.source.pathmap("%{src,ebin}d")} #{t.source}")
else
- sh("erlc -pa ebin -W #{ERLC_FLAGS} -o ebin #{t.source}")
+ sh("erlc -pa ebin -W #{ERLC_FLAGS} -o #{t.source.pathmap("%{src,ebin}d")} #{t.source}")
end
end
@@ -46,7 +46,7 @@ end
desc "Run Unit Tests"
task :test do
- sh("erl -noshell -pa #{PWD}/ebin -s eunit test #{TEST_MODULE} -s init stop")
+ sh("cd test; erl -noshell -pa #{PWD}/ebin -s eunit test #{TEST_MODULE} -s init stop")
end
desc "Generate Documentation"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -31,7 +31,7 @@ loop(InFile,Acc) ->
end.
parse_empty_file_test_() ->
- Path = filename:absname("tests/empty.proto"),
+ Path = filename:absname("protobuffs_testdata/empty.proto"),
[{message, "Empty", Messages}] = parse(Path),
[?_assertMatch({1,optional,"double","real1",number,none},lists:keyfind(1,1,Messages)),
?_assertMatch({2,optional,"float","real2",number,none},lists:keyfind(2,1,Messages)),
@@ -50,7 +50,7 @@ parse_empty_file_test_() ->
?_assertMatch({15,optional,"bytes","bit1",number,none},lists:keyfind(15,1,Messages))].
parse_has_default_test_() ->
- Path = filename:absname("tests/hasdefault.proto"),
+ Path = filename:absname("protobuffs_testdata/hasdefault.proto"),
[{message, "WithDefault", Messages}] = parse(Path),
[?_assertMatch({1,required,"double","real1",number,1.0},lists:keyfind(1,1,Messages)),
?_assertMatch({2,required,"float","real2",number,2.0},lists:keyfind(2,1,Messages)),
@@ -68,7 +68,7 @@ parse_has_default_test_() ->
?_assertMatch({14,required,"string","str1",number,"test"},lists:keyfind(14,1,Messages))].
parse_simple_test_() ->
- Path = filename:absname("tests/simple.proto"),
+ Path = filename:absname("protobuffs_testdata/simple.proto"),
[{package,"simple"},
{message, "Person", Person},
{message, "Location", Location}] = parse(Path),
@@ -81,15 +81,15 @@ parse_simple_test_() ->
?_assertMatch({2,required,"string","country",number,none},lists:keyfind(2,1,Location))].
parse_enum_test_() ->
- Path = filename:absname("tests/enum.proto"),
+ Path = filename:absname("protobuffs_testdata/enum.proto"),
[{message,"EnumMsg", EnumMsg}] = parse(Path),
{enum, "Values", Values} = lists:keyfind(enum,1,EnumMsg),
[?_assertMatch({1,optional,"Values","value",number,none},lists:keyfind(1,1,EnumMsg)),
?_assertMatch({enum,1,"value1"},lists:keyfind("value1",3,Values)),
?_assertMatch({enum,2,"value2"},lists:keyfind("value2",3,Values))].
parse_nested1_test_() ->
- Path = filename:absname("tests/nested1.proto"),
+ Path = filename:absname("protobuffs_testdata/nested1.proto"),
[{message, "Person", Person}] = parse(Path),
{message, "PhoneNumber", PhoneNumber} = lists:keyfind("PhoneNumber",2,Person),
{message, "PhoneType", PhoneType} = lists:keyfind("PhoneType",2,PhoneNumber),
@@ -103,7 +103,7 @@ parse_nested1_test_() ->
?_assertMatch({3,optional,"int32","work",number,none},lists:keyfind(3,1,PhoneType))].
parse_nested2_test_() ->
- Path = filename:absname("tests/nested2.proto"),
+ Path = filename:absname("protobuffs_testdata/nested2.proto"),
[{message, "Outer",Outer}] = parse(Path),
{message, "MiddleAA", MiddleAA} = lists:keyfind("MiddleAA",2,Outer),
{message, "MiddleBB", MiddleBB} = lists:keyfind("MiddleBB",2,Outer),
@@ -119,7 +119,7 @@ parse_nested2_test_() ->
?_assertMatch({2,optional,"bool","booly",number,none},lists:keyfind(2,1,InnerBB))].
parse_nested3_test_() ->
- Path = filename:absname("tests/nested3.proto"),
+ Path = filename:absname("protobuffs_testdata/nested3.proto"),
[{message,"Outer",Outer}] = parse(Path),
{message,"Middle",Middle} = lists:keyfind("Middle",2,Outer),
{message,"Other",Other} = lists:keyfind("Other",2,Outer),
@@ -131,7 +131,7 @@ parse_nested3_test_() ->
?_assertMatch({1,optional,"bool","bar",number,none},lists:keyfind(1,1,Other))].
parse_nested4_test_() ->
- Path = filename:absname("tests/nested4.proto"),
+ Path = filename:absname("protobuffs_testdata/nested4.proto"),
[{message,"Outer",Outer}] = parse(Path),
{message,"Middle",Middle} = lists:keyfind("Middle",2,Outer),
{message,"Other",Other} = lists:keyfind("Other",2,Outer),
@@ -143,7 +143,7 @@ parse_nested4_test_() ->
?_assertMatch({1,optional,"bool","bar",number,none},lists:keyfind(1,1,Other))].
parse_nested5_test_() ->
- Path = filename:absname("tests/nested5.proto"),
+ Path = filename:absname("protobuffs_testdata/nested5.proto"),
Parsed = parse(Path),
{message,"First",First} = lists:keyfind("First",2,Parsed),
{message,"Second",Second} = lists:keyfind("Second",2,Parsed),
@@ -156,7 +156,7 @@ prop_protobuffs_test_() ->
[?_assert(eqc:quickcheck(eqc:numtests(?NUM_TESTS,protobuffs_eqc:prop_protobuffs())))].
empty_setup() ->
- Path = filename:absname("tests/empty.proto"),
+ Path = filename:absname("protobuffs_testdata/empty.proto"),
protobuffs_compile:scan_file(Path).
teardown(_) ->
@@ -178,7 +178,7 @@ protobuffs_empty_test_() ->
}.
has_default_setup() ->
- Path = filename:absname("tests/hasdefault.proto"),
+ Path = filename:absname("protobuffs_testdata/hasdefault.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_has_default_test_() ->
@@ -197,7 +197,7 @@ protobuffs_has_default_test_() ->
}.
simple_setup() ->
- Path = filename:absname("tests/simple.proto"),
+ Path = filename:absname("protobuffs_testdata/simple.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_simple_test_() ->
@@ -216,7 +216,7 @@ protobuffs_simple_test_() ->
}.
nested1_setup() ->
- Path = filename:absname("tests/nested1.proto"),
+ Path = filename:absname("protobuffs_testdata/nested1.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_nested1_test_() ->
@@ -235,7 +235,7 @@ protobuffs_nested1_test_() ->
}.
nested2_setup() ->
- Path = filename:absname("tests/nested2.proto"),
+ Path = filename:absname("protobuffs_testdata/nested2.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_nested2_test_() ->
@@ -254,7 +254,7 @@ protobuffs_nested2_test_() ->
}.
nested3_setup() ->
- Path = filename:absname("tests/nested3.proto"),
+ Path = filename:absname("protobuffs_testdata/nested3.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_nested3_test_() ->
@@ -273,7 +273,7 @@ protobuffs_nested3_test_() ->
}.
nested4_setup() ->
- Path = filename:absname("tests/nested4.proto"),
+ Path = filename:absname("protobuffs_testdata/nested4.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_nested4_test_() ->
@@ -292,7 +292,7 @@ protobuffs_nested4_test_() ->
}.
nested5_setup() ->
- Path = filename:absname("tests/nested5.proto"),
+ Path = filename:absname("protobuffs_testdata/nested5.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_nested5_test_() ->
@@ -316,7 +316,7 @@ protobuffs_nested5_test_() ->
}.
enum_setup() ->
- Path = filename:absname("tests/enum.proto"),
+ Path = filename:absname("protobuffs_testdata/enum.proto"),
protobuffs_compile:scan_file(Path).
protobuffs_enum_test_() ->

0 comments on commit 9505808

Please sign in to comment.