Clean up logging from Lua 5.1 and 5.2 error debug. Add a little more
test coverage.
This commit is contained in:
parent
9d9fedf945
commit
37ec7cd173
|
@ -60,8 +60,6 @@ end
|
|||
-- Adding 'mkdir -p' functionality can be considered in the future.
|
||||
local function check_directory(directory)
|
||||
|
||||
print("Enter check_directory()")
|
||||
print(directory)
|
||||
if directory and type(directory) == "string" then
|
||||
|
||||
-- Fully qualify a "~/" path or a relative path to $HOME. One might argue
|
||||
|
@ -75,20 +73,15 @@ local function check_directory(directory)
|
|||
directory = string.gsub(os.getenv("HOME"), "/*$", "/", 1) .. directory
|
||||
end
|
||||
|
||||
print("After first sanitation -- " .. directory)
|
||||
|
||||
-- Assure that we return exactly one trailing slash
|
||||
directory = string.gsub(directory, '/*$', '/', 1)
|
||||
print("After second sanitation -- " .. directory)
|
||||
|
||||
if gears.filesystem.dir_writable(directory) then
|
||||
print("Returning directory")
|
||||
return directory
|
||||
else
|
||||
-- Currently returns nil if the requested directory string cannot be used.
|
||||
-- This can be swapped to a silent fallback to the default directory if
|
||||
-- desired. It is debatable which way is better.
|
||||
print("Returning nil")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
@ -96,7 +89,6 @@ local function check_directory(directory)
|
|||
-- No directory argument means use the default. Technically an outrageously
|
||||
-- invalid argument (i.e. not even a string) currently falls back to the
|
||||
-- default as well.
|
||||
print("Returning default directory")
|
||||
return get_default_dir()
|
||||
end
|
||||
|
||||
|
@ -719,19 +711,12 @@ function screenshot:filepath_builder(args)
|
|||
local directory = args.directory
|
||||
local prefix = args.prefix
|
||||
|
||||
print("Entering filepath_builder(args)")
|
||||
print(args.filepath)
|
||||
print(args.directory)
|
||||
print(args.prefix)
|
||||
|
||||
if filepath and check_filepath(filepath) then
|
||||
|
||||
print("First if in filepath_builder")
|
||||
directory, prefix = parse_filepath(filepath)
|
||||
|
||||
elseif directory or prefix then
|
||||
|
||||
print("Second if in filepath_builder")
|
||||
if directory and type(directory) == "string" then
|
||||
directory = check_directory(directory)
|
||||
elseif self.directory then
|
||||
|
@ -752,13 +737,11 @@ function screenshot:filepath_builder(args)
|
|||
|
||||
elseif self.filepath and check_filepath(self.filepath) then
|
||||
|
||||
print("Third if in filepath_builder")
|
||||
filepath = self.filepath
|
||||
directory, prefix = parse_filepath(filepath)
|
||||
|
||||
else
|
||||
|
||||
print("Else in filepath_builder")
|
||||
if self.directory then
|
||||
directory = self._private.directory -- The setter ran check_directory()
|
||||
else
|
||||
|
@ -772,10 +755,6 @@ function screenshot:filepath_builder(args)
|
|||
end
|
||||
|
||||
directory, prefix, filepath = make_filepath(directory, prefix)
|
||||
print("Finished building filepath:")
|
||||
print(directory)
|
||||
print(prefix)
|
||||
print(filepath)
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -194,33 +194,33 @@ table.insert(steps, function()
|
|||
--Make sure client from last test is gone
|
||||
if #client.get() ~= 0 then return end
|
||||
|
||||
print("Set blank defaults")
|
||||
local fake_screenshot_dir = string.gsub(fake_screenshot_dir, "/*$", "/", 1)
|
||||
|
||||
awful.screenshot.set_defaults({})
|
||||
print("Set explicit defaults")
|
||||
awful.screenshot.set_defaults({directory = "/dev/null", prefix = "Screenshot-", frame_color = "#000000"})
|
||||
print("Set tilde default")
|
||||
awful.screenshot.set_defaults({directory = "~/"})
|
||||
print("Set directory default")
|
||||
awful.screenshot.set_defaults({directory = fake_screenshot_dir})
|
||||
|
||||
print("Taking root shot")
|
||||
local ss = awful.screenshot.root()
|
||||
local name_prfx = string.gsub(fake_screenshot_dir, "/*$", "/") .. "Screenshot-"
|
||||
local name_prfx = fake_screenshot_dir .. "Screenshot-"
|
||||
|
||||
print("Checking assigned filepath")
|
||||
local f, l = string.find(ss.filepath, name_prfx)
|
||||
if f ~= 1 then
|
||||
print("Failed first if: " .. ss.filepath .. " : " .. name_prfx)
|
||||
print("Failed autogenerate filename: " .. ss.filepath .. " : " .. name_prfx)
|
||||
return false
|
||||
end
|
||||
|
||||
print("Assigning new filepath")
|
||||
name_prfx = string.gsub(fake_screenshot_dir, "/*$", "/") .. "MyShot.png"
|
||||
name_prfx = fake_screenshot_dir .. "MyShot.png"
|
||||
ss.filepath = name_prfx
|
||||
|
||||
print("Checking assigned filepath")
|
||||
if ss.filepath ~= name_prfx then
|
||||
print("Failed second if: " .. ss.filepath .. " : " .. name_prfx)
|
||||
print("Failed assign filename: " .. ss.filepath .. " : " .. name_prfx)
|
||||
return false
|
||||
end
|
||||
|
||||
ss:filepath_builder({directory = fake_screenshot_dir, prefix = "Screenshot-"})
|
||||
if ss.directory ~= fake_screenshot_dir or ss.prefix ~= "Screenshot-" then
|
||||
print("Failed assign directory/prefix: " .. ss.directory .. " : " .. ss.prefix)
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -230,13 +230,11 @@ end)
|
|||
|
||||
--Check the root window with awful.screenshot.root() method
|
||||
table.insert(steps, function()
|
||||
|
||||
local root_width, root_height = root.size()
|
||||
local ss = awful.screenshot.root()
|
||||
local img = ss.surface
|
||||
|
||||
if get_pixel(img, 100, 100) ~= "#00ff00" then return end
|
||||
if get_pixel(img, 2, 2) ~= "#ff0000" then return end
|
||||
|
||||
assert(get_pixel(img, 100, 100) == "#00ff00")
|
||||
assert(get_pixel(img, 199, 199) == "#00ff00")
|
||||
assert(get_pixel(img, 201, 201) ~= "#00ff00")
|
||||
|
@ -246,11 +244,20 @@ table.insert(steps, function()
|
|||
assert(get_pixel(img, 2, root_height - 2) == "#ff0000")
|
||||
assert(get_pixel(img, root_width - 2, root_height - 2) == "#ff0000")
|
||||
|
||||
if ss.screen ~= nil or ss.client ~= nil then
|
||||
print("Returned non nil screen or client for root screenshot")
|
||||
print(ss.screen)
|
||||
print(ss.client)
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end)
|
||||
|
||||
-- Check the awful.screenshot.screen() method
|
||||
table.insert(steps, function()
|
||||
|
||||
for s in screen do
|
||||
|
||||
local geo = s.geometry
|
||||
|
@ -269,6 +276,7 @@ table.insert(steps, function()
|
|||
spawn(tiny_client)
|
||||
|
||||
return true
|
||||
|
||||
end)
|
||||
|
||||
-- Check the awful.screenshot.client() method
|
||||
|
|
Loading…
Reference in New Issue