tests/examples: Move common template code into a common file (#993)

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-07-09 19:03:49 +02:00 committed by Daniel Hahler
parent 4cc6a8155f
commit a8834bfcc1
7 changed files with 38 additions and 110 deletions

View File

@ -1,30 +1,10 @@
local file_path, image_path, luacovpath = ... local file_path, image_path = ...
require("_common_template")(...)
local cairo = require("lgi").cairo local cairo = require("lgi").cairo
local pango = require("lgi").Pango local pango = require("lgi").Pango
local pangocairo = require("lgi").PangoCairo local pangocairo = require("lgi").PangoCairo
-- Set the global shims
-- luacheck: globals awesome root tag screen client mouse drawin
awesome = require( "awesome" )
root = require( "root" )
tag = require( "tag" )
screen = require( "screen" )
client = require( "client" )
mouse = require( "mouse" )
drawin = require( "drawin" )
-- Force luacheck to be silent about setting those as unused globals
assert(awesome and root and tag and screen and client and mouse)
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
local color = require( "gears.color" ) local color = require( "gears.color" )
local shape = require( "gears.shape" ) local shape = require( "gears.shape" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )

View File

@ -1,17 +1,11 @@
local filepath, svgpath = ...
require("_common_template")(...)
-- Test if shape crash when called -- Test if shape crash when called
-- Also generate some SVG to be used by the documentation -- Also generate some SVG to be used by the documentation
-- it also "prove" that the code examples are all working -- it also "prove" that the code examples are all working
local cairo = require( "lgi" ).cairo local cairo = require( "lgi" ).cairo
local shape = require( "gears.shape" ) local shape = require( "gears.shape" )
local filepath, svgpath, luacovpath = ...
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
local function get_surface(p) local function get_surface(p)
local img = cairo.SvgSurface.create(p, 288, 76) local img = cairo.SvgSurface.create(p, 288, 76)

View File

@ -0,0 +1,25 @@
return function(_, _, luacovpath)
-- Set the global shims
-- luacheck: globals awesome root tag screen client mouse drawin
awesome = require( "awesome" )
root = require( "root" )
tag = require( "tag" )
screen = require( "screen" )
client = require( "client" )
mouse = require( "mouse" )
drawin = require( "drawin" )
-- Force luacheck to be silent about setting those as unused globals
assert(awesome and root and tag and screen and client and mouse)
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,22 +1,5 @@
local file_path, _, luacovpath = ... local file_path = ...
require("_common_template")(...)
-- Set the global shims
-- luacheck: globals awesome root tag screen client mouse drawin
awesome = require( "awesome" )
root = require( "root" )
tag = require( "tag" )
screen = require( "screen" )
client = require( "client" )
mouse = require( "mouse" )
drawin = require( "drawin" )
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Execute the test -- Execute the test
loadfile(file_path)() loadfile(file_path)()

View File

@ -1,29 +1,11 @@
local file_path, image_path, luacovpath = ... local file_path, image_path = ...
require("_common_template")(...)
-- Set the global shims
-- luacheck: globals awesome client tag drawin screen
awesome = require( "awesome" )
client = require( "client" )
tag = require( "tag" )
drawin = require( "drawin" )
screen = require( "screen" )
-- Force luacheck to be silent about setting those as unused globals
assert(awesome and client and tag)
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local surface = require( "gears.surface" ) local surface = require( "gears.surface" )
local shape = require( "gears.shape" ) local shape = require( "gears.shape" )
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Let the test request a size and file format -- Let the test request a size and file format
local before, after = loadfile(file_path)() local before, after = loadfile(file_path)()

View File

@ -1,29 +1,11 @@
local file_path, image_path, luacovpath = ... local file_path, image_path = ...
require("_common_template")(...)
-- Set the global shims
-- luacheck: globals awesome client tag drawin screen
awesome = require( "awesome" )
client = require( "client" )
tag = require( "tag" )
drawin = require( "drawin" )
screen = require( "screen" )
-- Force luacheck to be silent about setting those as unused globals
assert(awesome and client and tag)
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local surface = require( "gears.surface" ) local surface = require( "gears.surface" )
local color = require( "gears.color" ) local color = require( "gears.color" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Create a generic rectangle widget to show layout disposition -- Create a generic rectangle widget to show layout disposition
local function generic_widget(text) local function generic_widget(text)
return { return {

View File

@ -1,27 +1,9 @@
local file_path, image_path, luacovpath = ... local file_path, image_path = ...
require("_common_template")(...)
-- Set the global shims
-- luacheck: globals awesome client tag drawin screen
awesome = require( "awesome" )
client = require( "client" )
tag = require( "tag" )
drawin = require( "drawin" )
screen = require( "screen" )
-- Force luacheck to be silent about setting those as unused globals
assert(awesome and client and tag)
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local surface = require( "gears.surface" ) local surface = require( "gears.surface" )
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- This is the main widget the tests will use as top level -- This is the main widget the tests will use as top level
local container = wibox.layout.fixed.vertical() local container = wibox.layout.fixed.vertical()