From f364eb68876d29c534f5e83fd69b0e15018591a4 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Fri, 13 Jun 2025 14:05:03 -0700 Subject: [PATCH] Use Path.exec instead of os.execute where we can --- spec/routes_spec.moon | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spec/routes_spec.moon b/spec/routes_spec.moon index 14b7798..93a4d6e 100644 --- a/spec/routes_spec.moon +++ b/spec/routes_spec.moon @@ -104,24 +104,26 @@ describe "http://miti.sh/posts", -> assert.same request\body!\match("(.*)"), "miti.sh ยท Posts" describe "http://git.miti.sh", -> - it "reverse proxies request to gitea through a unix socket", -> + it "reverse-proxies request to a gitea unix socket", -> Path = require "sitegen.path" socket_fname = "unixstreamsrvr.moon" socket_dir = "/run/gitea" socket_owner = "nobody" basepath = Path.basepath debug.getinfo(1).short_src - os.execute "mkdir " .. socket_dir - p = io.popen "moon %s"\format Path.join(basepath, socket_fname) - os.execute "sleep 0.1" - os.execute "chown -R " .. socket_owner .. " " .. socket_dir + Path.mkdir socket_dir + server = io.popen "moon %s"\format Path.join(basepath, socket_fname) + Path.exec "sleep", "0.1" + Path.exec "chown", "-R", socket_owner, socket_dir result = Path.read_exec "find", socket_dir, "-type", "s", "-ls" assert.truthy result\match "nobody%s+root.+" .. Path.join(socket_dir, "gitea.socket") - request = req "http://git.miti.sh" - pout = p\read"*a" - p\close! - assert.truthy pout\match "Host: git.miti.sh" + req "http://git.miti.sh" + + reqheader = with server\read "*a" + server\close! + + assert.truthy reqheader\match "Host: git.miti.sh" describe "http://apps.miti.sh", -> it "doesn't find it", ->