aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-28 13:33:57 +0100
committerLoïc Hoguin <[email protected]>2018-11-28 13:33:57 +0100
commit7a514c6a372219fee528e0bc2ed0b2f2ba9c758d (patch)
treea0f4ef115bf87479c319d4392e25825a1da9b18c /test
parent31c93f4ad6b55b90ccb07a047acb941af645c059 (diff)
downloaderlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.tar.gz
erlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.tar.bz2
erlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.zip
Modernize the protobuffs plugin
Diffstat (limited to 'test')
-rw-r--r--test/plugin_protobuffs.mk78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/plugin_protobuffs.mk b/test/plugin_protobuffs.mk
new file mode 100644
index 0000000..e3aad9f
--- /dev/null
+++ b/test/plugin_protobuffs.mk
@@ -0,0 +1,78 @@
+# Protocol buffers plugin.
+
+PROTOBUFFS_TARGETS = $(call list_targets,protobuffs)
+
+.PHONY: protobuffs $(PROTOBUFFS_TARGETS)
+
+protobuffs: $(PROTOBUFFS_TARGETS)
+
+PROTOBUFFS_URL = https://raw.githubusercontent.com/basho/erlang_protobuffs/master/test/erlang_protobuffs_SUITE_data
+
+protobuffs-compile: build clean
+
+ $i "Bootstrap a new OTP library named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Add protobuffs to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = protobuffs\n"}' $(APP)/Makefile
+
+ $i "Download two proto files"
+ $t mkdir $(APP)/src/proto/
+ $t curl -s -o $(APP)/src/proto/empty.proto $(PROTOBUFFS_URL)/proto/empty.proto
+ $t curl -s -o $(APP)/src/proto/simple.proto $(PROTOBUFFS_URL)/proto/simple.proto
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that an Erlang module was generated and compiled"
+ $t test -f $(APP)/src/empty_pb.erl
+ $t test -f $(APP)/src/simple_pb.erl
+ $t test -f $(APP)/include/empty_pb.hrl
+ $t test -f $(APP)/include/simple_pb.hrl
+ $t test -f $(APP)/ebin/empty_pb.beam
+ $t test -f $(APP)/ebin/simple_pb.beam
+
+ $i "Check that the generated modules are included in .app file"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:load($(APP)), \
+ {ok, [empty_pb, simple_pb]} = application:get_key($(APP), modules), \
+ halt()"
+
+protobuffs-makefile-change: build clean
+
+ $i "Bootstrap a new OTP library named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Add protobuffs to the list of dependencies"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = protobuffs\n"}' $(APP)/Makefile
+
+ $i "Download two proto files"
+ $t mkdir $(APP)/src/proto/
+ $t curl -s -o $(APP)/src/proto/empty.proto $(PROTOBUFFS_URL)/proto/empty.proto
+ $t curl -s -o $(APP)/src/proto/simple.proto $(PROTOBUFFS_URL)/proto/simple.proto
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Touch the Makefile; check that all files get rebuilt"
+ $t printf "%s\n" \
+ $(APP)/ebin/empty_pb.beam \
+ $(APP)/ebin/simple_pb.beam \
+ $(APP)/ebin/$(APP).app \
+ $(APP)/include/empty_pb.hrl \
+ $(APP)/include/simple_pb.hrl \
+ $(APP)/src/empty_pb.erl \
+ $(APP)/src/proto/simple.proto \
+ $(APP)/src/proto/empty.proto \
+ $(APP)/src/simple_pb.erl \
+ $(APP)/$(APP).d | sort > $(APP)/EXPECT
+ $t $(SLEEP)
+ $t touch $(APP)/Makefile
+ $t $(SLEEP)
+ $t $(MAKE) -C $(APP) $v
+ $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
+ $t rm $(APP)/EXPECT