From 941c9973148a47e84ba551c4cb43771582c139a3 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 14 Jun 2017 09:41:30 +0200 Subject: [PATCH] tests: Add a very basic test for the menubar This does not actually test anything. It just makes sure that the code runs. A proper test still seems to need some time and some hacks, but this basic test is enough to check that the menubar does not cause any Lua errors. Signed-off-by: Uli Schlachter --- tests/test-menubar.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test-menubar.lua diff --git a/tests/test-menubar.lua b/tests/test-menubar.lua new file mode 100644 index 000000000..7c746f64c --- /dev/null +++ b/tests/test-menubar.lua @@ -0,0 +1,36 @@ +-- Test the menubar + +local runner = require("_runner") +local menubar = require("menubar") + +runner.run_steps { + function(count) + -- Just show the menubar and hide it. + -- TODO: Write a proper test. But for the mean time this is better than + -- nothing (and tells us when errors are thrown). + + if count == 1 then + -- Remove the entry for $HOME/.... from the search path. We run with + -- HOME=/dev/null and this would cause an error message to be + -- printed which would be interpreted as the test failing + local entry = menubar.menu_gen.all_menu_dirs[1] + assert(string.find(entry, "/dev/null"), entry) + table.remove(menubar.menu_gen.all_menu_dirs, 1) + + menubar.show() + end + + -- Test that the async population of the menubar is done + if #menubar.menu_entries > 0 then + menubar.hide() + awesome.sync() + return true + end + end, + + function() + return true + end +} + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80