From d9640cf027327c9d368c2c6e04f5693cd8b98222 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Sat, 6 Mar 2021 19:48:32 +0100 Subject: [PATCH] Provide default for Lua executable env variable --- tests/_client.lua | 7 ++++++- tests/test-selection-getter.lua | 11 ++++++++--- tests/test-selection-transfer.lua | 15 ++++++++++----- tests/test-selection-watcher.lua | 11 ++++++++--- tests/test-spawn.lua | 7 ++++++- tests/test-titlebar.lua | 9 +++++++-- 6 files changed, 45 insertions(+), 15 deletions(-) diff --git a/tests/_client.lua b/tests/_client.lua index b06b6f60f..d9db30ab1 100644 --- a/tests/_client.lua +++ b/tests/_client.lua @@ -1,5 +1,10 @@ local spawn = require("awful.spawn") +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + -- This file provide a simple, yet flexible, test client. -- It is used to test the `ruled.client` @@ -106,7 +111,7 @@ local pipe local function init() if initialized then return end initialized = true - local cmd = { os.getenv("LUA_EXECUTABLE"), "-e", test_client_source } + local cmd = { lua_executable, "-e", test_client_source } local _, _, stdin, stdout, stderr = awesome.spawn(cmd, false, true, true, true) pipe = Gio.UnixOutputStream.new(stdin, true) stdout = Gio.UnixInputStream.new(stdout, true) diff --git a/tests/test-selection-getter.lua b/tests/test-selection-getter.lua index 0c8fbdbc7..6e37b79e6 100644 --- a/tests/test-selection-getter.lua +++ b/tests/test-selection-getter.lua @@ -8,6 +8,11 @@ local lgi = require("lgi") local Gio = lgi.Gio local GdkPixbuf = lgi.GdkPixbuf +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + local header = [[ local lgi = require("lgi") local Gdk = lgi.Gdk @@ -48,7 +53,7 @@ runner.run_steps{ -- Clear the clipboard to get to a known state function() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_and_clear_clipboard }, + spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) return true end, @@ -79,7 +84,7 @@ runner.run_steps{ -- Now set the clipboard to some text continue = false - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_clipboard_text }, + spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_text }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) @@ -143,7 +148,7 @@ runner.run_steps{ -- Now set the clipboard to an image continue = false - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_clipboard_pixbuf }, + spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_pixbuf }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) diff --git a/tests/test-selection-transfer.lua b/tests/test-selection-transfer.lua index d3d5936f3..a1d0b4b42 100644 --- a/tests/test-selection-transfer.lua +++ b/tests/test-selection-transfer.lua @@ -3,6 +3,11 @@ local runner = require("_runner") local spawn = require("awful.spawn") +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + -- Assemble data for the large transfer that will be done later local large_transfer_piece = "a" for _ = 1, 25 do @@ -86,7 +91,7 @@ runner.run_steps({ end end) awesome.sync() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", check_targets_and_text }, + spawn.with_line_callback({ lua_executable, "-e", check_targets_and_text }, { stdout = function(line) assert(line == "done", "Unexpected line: " .. line) continue = true @@ -124,7 +129,7 @@ runner.run_steps({ end end) awesome.sync() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", check_targets_and_text }, + spawn.with_line_callback({ lua_executable, "-e", check_targets_and_text }, { stdout = function(line) assert(line == "done", "Unexpected line: " .. line) continue = true @@ -161,7 +166,7 @@ runner.run_steps({ end end) awesome.sync() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", check_large_transfer }, + spawn.with_line_callback({ lua_executable, "-e", check_large_transfer }, { stdout = function(line) assert(line == "done", "Unexpected line: " .. line) continue = true @@ -177,7 +182,7 @@ runner.run_steps({ -- Now test that :release() works selection_object:release() awesome.sync() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", check_empty_selection }, + spawn.with_line_callback({ lua_executable, "-e", check_empty_selection }, { stdout = function(line) assert(line == "done", "Unexpected line: " .. line) continue = true @@ -196,7 +201,7 @@ runner.run_steps({ "Failed to acquire the clipboard selection") selection_object:connect_signal("release", function() selection_released = true end) awesome.sync() - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_and_clear_clipboard }, + spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) return true end, diff --git a/tests/test-selection-watcher.lua b/tests/test-selection-watcher.lua index b58552461..b781a118c 100644 --- a/tests/test-selection-watcher.lua +++ b/tests/test-selection-watcher.lua @@ -3,6 +3,11 @@ local runner = require("_runner") local spawn = require("awful.spawn") +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + local header = [[ local lgi = require("lgi") local Gdk = lgi.Gdk @@ -62,7 +67,7 @@ runner.run_steps{ -- Clear the clipboard to get to a known state function() check_state(0, 0) - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_and_clear_clipboard }, + spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) return true end, @@ -81,7 +86,7 @@ runner.run_steps{ -- Set the clipboard continue = false - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_clipboard }, + spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) @@ -100,7 +105,7 @@ runner.run_steps{ -- Now clear the clipboard again continue = false - spawn.with_line_callback({ os.getenv("LUA_EXECUTABLE"), "-e", acquire_and_clear_clipboard }, + spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) return true diff --git a/tests/test-spawn.lua b/tests/test-spawn.lua index 8c725eb9b..f58f03909 100644 --- a/tests/test-spawn.lua +++ b/tests/test-spawn.lua @@ -3,6 +3,11 @@ local runner = require("_runner") local spawn = require("awful.spawn") +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + local spawns_done = 0 local async_spawns_done = 0 local exit_yay, exit_snd = nil, nil @@ -11,7 +16,7 @@ local exit_yay, exit_snd = nil, nil -- * spawn with startup notification is covered by test-spawn-snid.lua local tiny_client = function(class) - return {os.getenv("LUA_EXECUTABLE"), "-e", [[ + return { lua_executable, "-e", [[ local lgi = require 'lgi' local Gtk = lgi.require('Gtk') local class = ']]..class..[[' diff --git a/tests/test-titlebar.lua b/tests/test-titlebar.lua index 5df1a2fda..79c441b52 100644 --- a/tests/test-titlebar.lua +++ b/tests/test-titlebar.lua @@ -4,6 +4,11 @@ local rules = require("ruled.client") local spawn = require("awful.spawn") local gdebug = require("gears.debug") +local lua_executable = os.getenv("LUA_EXECUTABLE") +if lua_executable == nil or lua_executable == "" then + lua_executable = "lua" +end + local tiny_client_code_template = [[ pcall(require, 'luarocks.loader') local Gtk, class = require('lgi').require('Gtk'), 'client' @@ -18,8 +23,8 @@ function app:on_activate() end app:run {''} ]] -local tiny_client = {os.getenv("LUA_EXECUTABLE"), "-e", string.format(tiny_client_code_template, "")} -local tiny_client_undecorated = {os.getenv("LUA_EXECUTABLE"), "-e", +local tiny_client = { lua_executable, "-e", string.format(tiny_client_code_template, "") } +local tiny_client_undecorated = { lua_executable, "-e", string.format(tiny_client_code_template, [[ window.decorated = false ]])