example tests: Save expected test output in a txt file
This commit adds a .txt file next to each example test that generates a text output. This text file contains the expected output and it is an error if the actual output does not match the expected output. This means that we no longer have to run the example tests before we can expand all the @foo@ expressions that occur. While touching this, I also fixed some typos and unexpected newlines in the tests' output. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
7469e992ff
commit
b5ca8bf937
|
@ -232,12 +232,17 @@ function(run_test test_path namespace escaped_content)
|
||||||
set(OUTPUT_IMAGE_PATH "")
|
set(OUTPUT_IMAGE_PATH "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Does the text generate text output?
|
||||||
# If there is an output, assume it is relevant and add it to the
|
# If there is an output, assume it is relevant and add it to the
|
||||||
# documentation under the image.
|
# documentation under the image.
|
||||||
if(NOT ${TEST_OUTPUT} STREQUAL "")
|
if(tmp_content MATCHES "--DOC_GEN_OUTPUT")
|
||||||
if(NOT tmp_content MATCHES "--DOC_GEN_OUTPUT")
|
# The expected output is next to the .lua file in a .output.txt file
|
||||||
message(FATAL_ERROR "Unexpected output from ${test_path}: ${TEST_OUTPUT}")
|
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()
|
endif()
|
||||||
|
|
||||||
set(TEST_DOC_CONTENT
|
set(TEST_DOC_CONTENT
|
||||||
"${TEST_DOC_CONTENT}\n${DOC_LINE_PREFIX}\n${DOC_LINE_PREFIX}**Usage example output**:\n${DOC_LINE_PREFIX}"
|
"${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 " "
|
"${TEST_DOC_CONTENT}" TEST_DOC_CONTENT " "
|
||||||
)
|
)
|
||||||
set(TEST_DOC_CONTENT "${TEST_DOC_CONTENT}\n${DOC_LINE_PREFIX}")
|
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()
|
endif()
|
||||||
|
|
||||||
# If there is some @* content, append it.
|
# If there is some @* content, append it.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
235
|
|
@ -0,0 +1 @@
|
||||||
|
Closest corner: top_left
|
|
@ -0,0 +1,2 @@
|
||||||
|
Before: x=-30, y=-30, width=100, height=100
|
||||||
|
After: x=10, y=10, width=100, height=100
|
|
@ -23,7 +23,7 @@ function class:set_foo(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function class:method(a, b, c)
|
function class:method(a, b, c)
|
||||||
print("In a mathod", a, b, c)
|
print("In a method", a, b, c)
|
||||||
end
|
end
|
||||||
|
|
||||||
local o = gears.object {
|
local o = gears.object {
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,2 @@
|
||||||
|
In slot [obj] nil nil nil
|
||||||
|
In slot [obj] foo bar 42
|
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
l:add_widget_at(new, 1, 4, 1, 1)
|
|
@ -0,0 +1 @@
|
||||||
|
l:extend_column(2)
|
|
@ -0,0 +1 @@
|
||||||
|
l:insert_column(2)
|
|
@ -10,8 +10,7 @@ print([[l = wibox.layout {
|
||||||
layout = wibox.layout.grid
|
layout = wibox.layout.grid
|
||||||
}
|
}
|
||||||
l:set_orientation("vertical") -- change to "horizontal"
|
l:set_orientation("vertical") -- change to "horizontal"
|
||||||
l:add(...)
|
l:add(...)]]) --DOC_HIDE
|
||||||
]]) --DOC_HIDE
|
|
||||||
|
|
||||||
return --DOC_HIDE
|
return --DOC_HIDE
|
||||||
wibox.widget {
|
wibox.widget {
|
||||||
|
|
|
@ -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(...)
|
|
@ -0,0 +1 @@
|
||||||
|
l:remove_widgets_at(1,1)
|
|
@ -0,0 +1 @@
|
||||||
|
l:remove_column(2)
|
Loading…
Reference in New Issue