diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 68514756..4cb869f6 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -232,12 +232,17 @@ function(run_test test_path namespace escaped_content) set(OUTPUT_IMAGE_PATH "") endif() + # Does the text generate text output? # If there is an output, assume it is relevant and add it to the # documentation under the image. - if(NOT ${TEST_OUTPUT} STREQUAL "") - if(NOT tmp_content MATCHES "--DOC_GEN_OUTPUT") - message(FATAL_ERROR "Unexpected output from ${test_path}: ${TEST_OUTPUT}") + if(tmp_content MATCHES "--DOC_GEN_OUTPUT") + # The expected output is next to the .lua file in a .output.txt file + string(REPLACE ".lua" ".output.txt" expected_output_path ${test_path}) + file(READ "${expected_output_path}" expected_output) + if(NOT "${TEST_OUTPUT}" STREQUAL "${expected_output}") + message(SEND_ERROR "Wrong output from ${test_path}:\nExpected:\n${expected_output}\nGot:\n${TEST_OUTPUT}") endif() + set(TEST_DOC_CONTENT "${TEST_DOC_CONTENT}\n${DOC_LINE_PREFIX}\n${DOC_LINE_PREFIX}**Usage example output**:\n${DOC_LINE_PREFIX}" ) @@ -248,6 +253,10 @@ function(run_test test_path namespace escaped_content) "${TEST_DOC_CONTENT}" TEST_DOC_CONTENT " " ) set(TEST_DOC_CONTENT "${TEST_DOC_CONTENT}\n${DOC_LINE_PREFIX}") + else() + if(NOT ${TEST_OUTPUT} STREQUAL "") + message(FATAL_ERROR "Unexpected output from ${test_path}: ${TEST_OUTPUT}") + endif() endif() # If there is some @* content, append it. diff --git a/tests/examples/awful/mouse/coords.output.txt b/tests/examples/awful/mouse/coords.output.txt new file mode 100644 index 00000000..f8c9d43a --- /dev/null +++ b/tests/examples/awful/mouse/coords.output.txt @@ -0,0 +1 @@ +235 diff --git a/tests/examples/awful/placement/closest_mouse.output.txt b/tests/examples/awful/placement/closest_mouse.output.txt new file mode 100644 index 00000000..ff6126c6 --- /dev/null +++ b/tests/examples/awful/placement/closest_mouse.output.txt @@ -0,0 +1 @@ +Closest corner: top_left diff --git a/tests/examples/awful/placement/no_offscreen.output.txt b/tests/examples/awful/placement/no_offscreen.output.txt new file mode 100644 index 00000000..e6857e61 --- /dev/null +++ b/tests/examples/awful/placement/no_offscreen.output.txt @@ -0,0 +1,2 @@ +Before: x=-30, y=-30, width=100, height=100 +After: x=10, y=10, width=100, height=100 diff --git a/tests/examples/text/gears/object/properties.lua b/tests/examples/text/gears/object/properties.lua index ffb05ddc..09b82bf3 100644 --- a/tests/examples/text/gears/object/properties.lua +++ b/tests/examples/text/gears/object/properties.lua @@ -23,7 +23,7 @@ function class:set_foo(value) end function class:method(a, b, c) - print("In a mathod", a, b, c) + print("In a method", a, b, c) end local o = gears.object { diff --git a/tests/examples/text/gears/object/properties.output.txt b/tests/examples/text/gears/object/properties.output.txt new file mode 100644 index 00000000..16f4a60d --- /dev/null +++ b/tests/examples/text/gears/object/properties.output.txt @@ -0,0 +1,9 @@ +In get foo bar +bar +In set foo 42 +In get foo 42 +42 +In a method 1 2 3 +nil +In the connection handler! a cow +a cow diff --git a/tests/examples/text/gears/object/signal.output.txt b/tests/examples/text/gears/object/signal.output.txt new file mode 100644 index 00000000..c73dae3a --- /dev/null +++ b/tests/examples/text/gears/object/signal.output.txt @@ -0,0 +1,2 @@ +In slot [obj] nil nil nil +In slot [obj] foo bar 42 diff --git a/tests/examples/text/gears/sort/topological.output.txt b/tests/examples/text/gears/sort/topological.output.txt new file mode 100644 index 00000000..8c2c033b --- /dev/null +++ b/tests/examples/text/gears/sort/topological.output.txt @@ -0,0 +1,6 @@ +The position #1 is: a +The position #2 is: b +The position #3 is: c +The position #4 is: d +The position #5 is: e +The position #6 is: f diff --git a/tests/examples/wibox/layout/grid/add.output.txt b/tests/examples/wibox/layout/grid/add.output.txt new file mode 100644 index 00000000..aa38c48a --- /dev/null +++ b/tests/examples/wibox/layout/grid/add.output.txt @@ -0,0 +1 @@ +l:add_widget_at(new, 1, 4, 1, 1) diff --git a/tests/examples/wibox/layout/grid/extend_column.output.txt b/tests/examples/wibox/layout/grid/extend_column.output.txt new file mode 100644 index 00000000..ac9b51d8 --- /dev/null +++ b/tests/examples/wibox/layout/grid/extend_column.output.txt @@ -0,0 +1 @@ +l:extend_column(2) diff --git a/tests/examples/wibox/layout/grid/insert_column.output.txt b/tests/examples/wibox/layout/grid/insert_column.output.txt new file mode 100644 index 00000000..3c10daf8 --- /dev/null +++ b/tests/examples/wibox/layout/grid/insert_column.output.txt @@ -0,0 +1 @@ +l:insert_column(2) diff --git a/tests/examples/wibox/layout/grid/orientation.lua b/tests/examples/wibox/layout/grid/orientation.lua index 8a36679e..d0274925 100644 --- a/tests/examples/wibox/layout/grid/orientation.lua +++ b/tests/examples/wibox/layout/grid/orientation.lua @@ -10,8 +10,7 @@ print([[l = wibox.layout { layout = wibox.layout.grid } l:set_orientation("vertical") -- change to "horizontal" -l:add(...) -]]) --DOC_HIDE +l:add(...)]]) --DOC_HIDE return --DOC_HIDE wibox.widget { diff --git a/tests/examples/wibox/layout/grid/orientation.output.txt b/tests/examples/wibox/layout/grid/orientation.output.txt new file mode 100644 index 00000000..cb19909a --- /dev/null +++ b/tests/examples/wibox/layout/grid/orientation.output.txt @@ -0,0 +1,8 @@ +l = wibox.layout { + forced_num_cols = 2, + forced_num_rows = 2, + homogeneous = true, + layout = wibox.layout.grid +} +l:set_orientation("vertical") -- change to "horizontal" +l:add(...) diff --git a/tests/examples/wibox/layout/grid/remove.output.txt b/tests/examples/wibox/layout/grid/remove.output.txt new file mode 100644 index 00000000..f4d239e8 --- /dev/null +++ b/tests/examples/wibox/layout/grid/remove.output.txt @@ -0,0 +1 @@ +l:remove_widgets_at(1,1) diff --git a/tests/examples/wibox/layout/grid/remove_column.output.txt b/tests/examples/wibox/layout/grid/remove_column.output.txt new file mode 100644 index 00000000..b8e5d85e --- /dev/null +++ b/tests/examples/wibox/layout/grid/remove_column.output.txt @@ -0,0 +1 @@ +l:remove_column(2)