diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 27 | ||||
-rw-r--r-- | test/core_compat.mk | 37 | ||||
-rw-r--r-- | test/core_deps.mk | 2 | ||||
-rw-r--r-- | test/plugin_asciidoc.mk | 158 | ||||
-rw-r--r-- | test/plugin_bootstrap.mk | 4 | ||||
-rw-r--r-- | test/plugin_ct.mk | 13 | ||||
-rw-r--r-- | test/plugin_edoc.mk | 112 |
7 files changed, 321 insertions, 32 deletions
diff --git a/test/Makefile b/test/Makefile index 728d751..f01e3ab 100644 --- a/test/Makefile +++ b/test/Makefile @@ -303,9 +303,9 @@ endef # The following tests are slowly being converted. # Do NOT use -j with legacy tests. -.PHONY: legacy clean-legacy tests-cover docs +.PHONY: legacy clean-legacy tests-cover -legacy: clean-legacy tests-cover docs pkgs +legacy: clean-legacy tests-cover clean-legacy: $t rm -rf app1 @@ -345,29 +345,6 @@ tests-cover: app1 $t $(MAKE) -C app1 clean $v $i "Test 'tests-cover' passed." -docs: app1 - $i "docs: Testing EDoc including DOC_DEPS." - $t printf "%s\n" \ - "PROJECT = app1" \ - "DOC_DEPS = edown" \ - "dep_edown = git https://github.com/uwiger/edown.git 0.7" \ - "EDOC_OPTS = {doclet, edown_doclet}" \ - "include erlang.mk" \ - "distclean:: distclean-doc-md" \ - "distclean-doc-md:" \ - " rm -rf doc/*.md" \ - > app1/Makefile-doc - $i "Downloading doc deps (edown) and building docs." - $t $(MAKE) -C app1 -f Makefile-doc docs $v - $i "Checking that '$(MAKE) docs' using edown generated a markdown file." - $t [ -e app1/doc/m.md ] - $i "Checking that '$(MAKE) distclean' deletes all generated doc files." - $t $(MAKE) -C app1 -f Makefile-doc distclean $v - $t [ "`ls app1/doc/`" = "" ] - $i "Cleaning up test data." - $t rm app1/Makefile-doc - $i "Test 'docs' passed." - define app1_setup $i "Setting up app." $t mkdir -p app1 diff --git a/test/core_compat.mk b/test/core_compat.mk index 73a9da1..8d6cabc 100644 --- a/test/core_compat.mk +++ b/test/core_compat.mk @@ -2,10 +2,11 @@ # # Note: autopatch functionality is covered separately. -CORE_COMPAT_CASES = auto-rebar rebar rebar-deps rebar-deps-pkg rebar-erlc-opts rebar-pt +CORE_COMPAT_CASES = auto-rebar rebar rebar-deps-git rebar-deps-hex rebar-deps-pkg rebar-erlc-opts rebar-pt CORE_COMPAT_TARGETS = $(addprefix core-compat-,$(CORE_COMPAT_CASES)) REBAR_BINARY = https://github.com/rebar/rebar/releases/download/2.6.0/rebar +REBAR3_BINARY = https://s3.amazonaws.com/rebar3/rebar3 .PHONY: core-compat $(CORE_COMPAT_TARGETS) @@ -92,7 +93,7 @@ core-compat-rebar: build clean $i "Use rebar to build the application" $t cd $(APP) && ./rebar compile $v -core-compat-rebar-deps: build clean +core-compat-rebar-deps-git: build clean $i "Bootstrap a new OTP library named $(APP)" $t mkdir $(APP)/ @@ -124,6 +125,38 @@ core-compat-rebar-deps: build clean $i "Use rebar to build the application" $t cd $(APP) && ./rebar get-deps compile $v +core-compat-rebar-deps-hex: 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 Cowboy as a dependency" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile + + $i "Run 'make rebar.config'" + $t $(MAKE) -C $(APP) rebar.config $v + + $i "Check that rebar.config was created" + $t test -f $(APP)/rebar.config + + $i "Check that Cowboy is listed in rebar.config" + $t $(ERL) -eval " \ + {ok, C} = file:consult(\"$(APP)/rebar.config\"), \ + {_, [{cowboy, \"1.0.0\"}]} = lists:keyfind(deps, 1, C), \ + halt()" + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $i "Download rebar3" + $t curl -s -L -o $(APP)/rebar3 $(REBAR3_BINARY) + $t chmod +x $(APP)/rebar3 + + $i "Use rebar to build the application" + $t cd $(APP) && ./rebar3 compile $v + core-compat-rebar-deps-pkg: build clean $i "Bootstrap a new OTP library named $(APP)" diff --git a/test/core_deps.mk b/test/core_deps.mk index c383d94..f145754 100644 --- a/test/core_deps.mk +++ b/test/core_deps.mk @@ -591,7 +591,7 @@ core-deps-doc: build clean halt()" $i "Build the application documentation" - $t $(MAKE) -C $(APP) docs $v + $t $(MAKE) -C $(APP) edoc $v $i "Check that documentation dependencies were fetched" $t test -d $(APP)/deps/edown diff --git a/test/plugin_asciidoc.mk b/test/plugin_asciidoc.mk new file mode 100644 index 0000000..a583585 --- /dev/null +++ b/test/plugin_asciidoc.mk @@ -0,0 +1,158 @@ +# AsciiDoc plugin. + +ASCIIDOC_CASES = build docs guide install manual +ASCIIDOC_TARGETS = $(addprefix asciidoc-,$(ASCIIDOC_CASES)) + +.PHONY: asciidoc $(ASCIIDOC_TARGETS) + +asciidoc: $(ASCIIDOC_TARGETS) + +asciidoc-build: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Only enable man pages section 3" + $t perl -ni.bak -e 'print;if ($$.==1) {print "MAN_SECTIONS = 3\n"}' $(APP)/Makefile + + $i "Run AsciiDoc" + $t $(MAKE) -C $(APP) asciidoc $v + + $i "Check that no documentation was generated" + $t test ! -e $(APP)/doc/guide.pdf + $t test ! -e $(APP)/doc/html/ + $t test ! -e $(APP)/doc/man3/ + + $i "Generate AsciiDoc documentation" + $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/ + $t printf "%s\n" \ + "= Erlang.mk tests" "" \ + "Hello world!" > $(APP)/doc/src/guide/book.asciidoc + $t printf "%s\n" \ + "= erlang_mk(3)" "" \ + "== Name" "" \ + "erlang_mk - Erlang.mk test" "" \ + "== Description" "" \ + "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc + + $i "Run AsciiDoc" + $t $(MAKE) -C $(APP) asciidoc $v + + $i "Check that the documentation was generated" + $t test -f $(APP)/doc/guide.pdf + $t test -d $(APP)/doc/html/ + $t test -f $(APP)/doc/man3/erlang_mk.3.gz + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $i "Check that the generated documentation was removed" + $t test ! -e $(APP)/doc/guide.pdf + $t test ! -e $(APP)/doc/html/ + $t test ! -e $(APP)/doc/man3/ + + $i "Generate an invalid AsciiDoc file" + $t printf "%s\n" \ + "= fail(3)" "" \ + "This will fail because the Name section is missing." > $(APP)/doc/src/manual/fail.asciidoc + + $i "Check that AsciiDoc errors out" + $t ! $(MAKE) -C $(APP) asciidoc $v + +asciidoc-docs: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Generate AsciiDoc documentation" + $t mkdir -p $(APP)/doc/src/guide/ + $t printf "%s\n" \ + "= Erlang.mk tests" "" \ + "Hello world!" > $(APP)/doc/src/guide/book.asciidoc + + $i "Check that AsciiDoc runs on 'make docs'" + $t $(MAKE) -C $(APP) docs $v + $t test -f $(APP)/doc/guide.pdf + $t test -d $(APP)/doc/html/ + +asciidoc-guide: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Generate AsciiDoc documentation" + $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/ + $t printf "%s\n" \ + "= Erlang.mk tests" "" \ + "Hello world!" > $(APP)/doc/src/guide/book.asciidoc + $t printf "%s\n" \ + "= erlang_mk(3)" "" \ + "== Name" "" \ + "erlang_mk - Erlang.mk test" "" \ + "== Description" "" \ + "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc + + $i "Check that only the guide is generated on 'make asciidoc-guide'" + $t $(MAKE) -C $(APP) asciidoc-guide $v + $t test -f $(APP)/doc/guide.pdf + $t test -d $(APP)/doc/html/ + $t test ! -e $(APP)/doc/man3/ + +asciidoc-install: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Only enable man pages section 3" + $t perl -ni.bak -e 'print;if ($$.==1) {print "MAN_SECTIONS = 3\n"}' $(APP)/Makefile + + $i "Generate AsciiDoc documentation" + $t mkdir -p $(APP)/doc/src/manual/ + $t printf "%s\n" \ + "= erlang_mk(3)" "" \ + "== Name" "" \ + "erlang_mk - Erlang.mk test" "" \ + "== Description" "" \ + "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc + + $i "Build and install the man pages to $(APP)/installed/" + $t $(MAKE) -C $(APP) install-docs MAN_INSTALL_PATH=installed/share $v + + $i "Check that the documentation was installed properly" + $t test -f $(APP)/installed/share/man3/erlang_mk.3.gz + +asciidoc-manual: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Only enable man pages section 3" + $t perl -ni.bak -e 'print;if ($$.==1) {print "MAN_SECTIONS = 3\n"}' $(APP)/Makefile + + $i "Generate AsciiDoc documentation" + $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/ + $t printf "%s\n" \ + "= Erlang.mk tests" "" \ + "Hello world!" > $(APP)/doc/src/guide/book.asciidoc + $t printf "%s\n" \ + "= erlang_mk(3)" "" \ + "== Name" "" \ + "erlang_mk - Erlang.mk test" "" \ + "== Description" "" \ + "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc + + $i "Check that only the manual is generated on 'make asciidoc-manual'" + $t $(MAKE) -C $(APP) asciidoc-manual $v + $t test ! -e $(APP)/doc/guide.pdf + $t test ! -e $(APP)/doc/html/ + $t test -f $(APP)/doc/man3/erlang_mk.3.gz diff --git a/test/plugin_bootstrap.mk b/test/plugin_bootstrap.mk index ebfa6e7..2b62b6f 100644 --- a/test/plugin_bootstrap.mk +++ b/test/plugin_bootstrap.mk @@ -190,6 +190,7 @@ bootstrap-templates: build clean $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_rest n=my_rest $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_ws n=my_ws $t $(MAKE) -C $(APP) --no-print-directory new t=ranch_protocol n=my_protocol + $t $(MAKE) -C $(APP) --no-print-directory new t=module n=my_module # Here we disable warnings because templates contain missing behaviors. $i "Build the application" @@ -200,11 +201,12 @@ bootstrap-templates: build clean $t test -f $(APP)/ebin/my_fsm.beam $t test -f $(APP)/ebin/my_server.beam $t test -f $(APP)/ebin/my_sup.beam + $t test -f $(APP)/ebin/my_module.beam $i "Check that all the modules can be loaded" $t $(ERL) -pa $(APP)/ebin/ -eval " \ ok = application:start($(APP)), \ - {ok, Mods = [my_fsm, my_http, my_loop, my_protocol, my_rest, my_server, my_sup, my_ws]} \ + {ok, Mods = [my_fsm, my_http, my_loop, my_module, my_protocol, my_rest, my_server, my_sup, my_ws]} \ = application:get_key($(APP), modules), \ [{module, M} = code:load_file(M) || M <- Mods], \ halt()" diff --git a/test/plugin_ct.mk b/test/plugin_ct.mk index dd36801..c32fa36 100644 --- a/test/plugin_ct.mk +++ b/test/plugin_ct.mk @@ -63,6 +63,12 @@ ct-apps-only: build clean $i "Create a new library named my_lib" $t $(MAKE) -C $(APP) new-lib in=my_lib $v + $i "Populate my_lib" + $t printf "%s\n" \ + "-module(my_lib)." \ + "-export([random_int/0])." \ + "random_int() -> 4." > $(APP)/apps/my_lib/src/my_lib.erl + $i "Check that Common Test detects no tests" $t $(MAKE) -C $(APP) ct | grep -q "Nothing to be done for 'ct'." @@ -70,9 +76,10 @@ ct-apps-only: build clean $t mkdir $(APP)/apps/my_app/test $t printf "%s\n" \ "-module(my_app_SUITE)." \ - "-export([all/0, ok/1])." \ - "all() -> [ok]." \ - "ok(_) -> ok." > $(APP)/apps/my_app/test/my_app_SUITE.erl + "-export([all/0, ok/1, call_my_lib/1])." \ + "all() -> [ok, call_my_lib]." \ + "ok(_) -> ok." \ + "call_my_lib(_) -> 4 = my_lib:random_int()." > $(APP)/apps/my_app/test/my_app_SUITE.erl $i "Generate a Common Test suite in my_lib" $t mkdir $(APP)/apps/my_lib/test diff --git a/test/plugin_edoc.mk b/test/plugin_edoc.mk new file mode 100644 index 0000000..33f3d0f --- /dev/null +++ b/test/plugin_edoc.mk @@ -0,0 +1,112 @@ +# EDoc plugin. + +EDOC_CASES = build docs no-overview opts +EDOC_TARGETS = $(addprefix edoc-,$(EDOC_CASES)) + +.PHONY: edoc $(EDOC_TARGETS) + +edoc: $(EDOC_TARGETS) + +edoc-build: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Run EDoc" + $t $(MAKE) -C $(APP) edoc $v + + $i "Check that documentation was generated" + $t test -f $(APP)/doc/index.html + $t test -f $(APP)/doc/$(APP)_app.html + $t test -f $(APP)/doc/$(APP)_sup.html + + $i "Distclean the application" + $t $(MAKE) -C $(APP) distclean $v + + $i "Check that the generated documentation was removed" + $t test ! -e $(APP)/doc/index.html + $t test ! -e $(APP)/doc/$(APP)_app.html + $t test ! -e $(APP)/doc/$(APP)_sup.html + + $i "Generate a module with EDoc comments" + $t printf "%s\n" \ + "%% @doc erlang-mk-edoc-module" \ + "-module($(APP))." \ + "-export([ok/0])." \ + "" \ + "%% @doc erlang-mk-edoc-function" \ + "ok() -> ok." > $(APP)/src/$(APP).erl + + $i "Run EDoc" + $t $(MAKE) -C $(APP) edoc $v + + $i "Check that the new module's documentation was generated" + $t test -f $(APP)/doc/$(APP).html + + $i "Check that the EDoc comments are in the generated documentation" + $t grep -q erlang-mk-edoc-module $(APP)/doc/$(APP).html + $t grep -q erlang-mk-edoc-function $(APP)/doc/$(APP).html + + $i "Generate a module with an invalid EDoc comment" + $t printf "%s\n" \ + "-module($(APP)_fail)." \ + "-export([fail/0])." \ + "%% @spec lol" \ + "fail() -> fail." > $(APP)/src/$(APP)_fail.erl + + $i "Check that EDoc errors out" + $t ! $(MAKE) -C $(APP) edoc $v + +edoc-docs: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Generate a doc/overview.edoc file" + $t mkdir $(APP)/doc + $t printf "%s\n" \ + "@author R. J. Hacker <[email protected]>" \ + "@copyright 2007 R. J. Hacker" \ + "@version 1.0.0" \ + "@title Welcome to the 'frob' application!" \ + "@doc 'frob' is a highly advanced frobnicator with low latency," > $(APP)/doc/overview.edoc + + $i "Check that EDoc runs on 'make docs'" + $t $(MAKE) -C $(APP) docs $v + $t test -f $(APP)/doc/index.html + + $i "Check that the overview.edoc file was used" + $t grep -q frobnicator $(APP)/doc/overview-summary.html + +edoc-no-overview: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Check that EDoc doesn't run on 'make docs'" + $t $(MAKE) -C $(APP) docs $v + $t test ! -e $(APP)/doc/index.html + +edoc-opts: build clean + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Add edown doclet for EDoc" + $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile + + $i "Run EDoc" + $t $(MAKE) -C $(APP) edoc $v + + $i "Check that the Markdown documentation was generated" + $t test -f $(APP)/doc/README.md + $t test -f $(APP)/doc/$(APP)_app.md + $t test -f $(APP)/doc/$(APP)_sup.md |