From 8e2d844f6051c01c37a8a2e1f83c053e1ebc0197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sun, 2 Jul 2017 16:02:36 +0200 Subject: [PATCH] Use luafilesystem to change directory In some circumstances, if not every syscall was somehow redefined, the directory was not changed correctly. With luafilesystem.chdir it is assured that we are in the wanted directory afterwards. --- spec/awful/completion_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/awful/completion_spec.lua b/spec/awful/completion_spec.lua index 6bc274eb4..05deab19e 100644 --- a/spec/awful/completion_spec.lua +++ b/spec/awful/completion_spec.lua @@ -6,6 +6,7 @@ end local gfs = require("gears.filesystem") local Gio = require("lgi").Gio local GLib = require("lgi").GLib +local lfs = require("lfs") local has_bash = GLib.find_program_in_path("bash") local has_zsh = GLib.find_program_in_path("zsh") @@ -60,12 +61,14 @@ end describe("awful.completion.shell in empty directory", function() local orig_popen = io.popen + local orig_dir = lfs.currentdir() setup(function() test_dir = get_test_dir() io.popen = function(...) --luacheck: ignore return orig_popen(string.format('cd %s && ', test_dir) .. ...) end + lfs.chdir(test_dir) test_path = get_test_path_dir() end) @@ -73,6 +76,7 @@ describe("awful.completion.shell in empty directory", function() assert.True(os.remove(test_dir)) io.popen = orig_popen --luacheck: ignore remove_test_path_dir(test_path) + lfs.chdir(orig_dir) end) if has_bash then @@ -92,6 +96,7 @@ end) describe("awful.completion.shell", function() local orig_popen = io.popen + local orig_dir = lfs.currentdir() setup(function() test_dir = get_test_dir() @@ -102,6 +107,7 @@ describe("awful.completion.shell", function() io.popen = function(...) --luacheck: ignore return orig_popen(string.format('cd %s && ', test_dir) .. ...) end + lfs.chdir(test_dir) test_path = get_test_path_dir() end) @@ -112,6 +118,7 @@ describe("awful.completion.shell", function() assert.True(os.remove(test_dir)) io.popen = orig_popen --luacheck: ignore remove_test_path_dir(test_path) + lfs.chdir(orig_dir) end) if has_bash then