diff options
author | Sewbacca <sewbacca@kolabnow.com> | 2024-03-04 12:57:12 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-04 21:52:09 +0000 |
commit | 1f3e8794254d32d44c510e3868378b2f969b0ba6 (patch) | |
tree | 2e0826d5f4694223f4fe7f81e537b280749b33a0 /spec/unit | |
parent | 531393e338746830aa6138c2f671ffc4e4db9e28 (diff) | |
download | luarocks-1f3e8794254d32d44c510e3868378b2f969b0ba6.tar.gz luarocks-1f3e8794254d32d44c510e3868378b2f969b0ba6.tar.bz2 luarocks-1f3e8794254d32d44c510e3868378b2f969b0ba6.zip |
tests: add tests for fs.execute_env using variables with spaces
Co-Authored-By: Hisham Muhammad <hisham@gobolinux.org>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/fs_spec.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/unit/fs_spec.lua b/spec/unit/fs_spec.lua index 5718aea4..621a7727 100644 --- a/spec/unit/fs_spec.lua +++ b/spec/unit/fs_spec.lua | |||
@@ -1541,4 +1541,55 @@ describe("luarocks.fs #unit", function() | |||
1541 | end) | 1541 | end) |
1542 | end) | 1542 | end) |
1543 | 1543 | ||
1544 | describe("fs.execute_env", function() | ||
1545 | local tmpname | ||
1546 | local tmplua | ||
1547 | local LUA = "lua" | ||
1548 | |||
1549 | local function readfile(pathname) | ||
1550 | local file = assert(io.open(pathname, "rb")) | ||
1551 | local data = file:read "*a" | ||
1552 | file:close() | ||
1553 | return data | ||
1554 | end | ||
1555 | |||
1556 | lazy_setup(function() | ||
1557 | tmpname = os.tmpname() | ||
1558 | |||
1559 | tmplua = os.tmpname() | ||
1560 | local f = assert(io.open(tmplua, 'wb')) | ||
1561 | f:write [[ | ||
1562 | local out = io.open((...), 'wb') | ||
1563 | out:write(os.getenv 'FOO') | ||
1564 | out:close() | ||
1565 | ]] | ||
1566 | f:close() | ||
1567 | LUA = test_env.testing_paths.lua | ||
1568 | end) | ||
1569 | |||
1570 | after_each(function() | ||
1571 | os.remove(tmpname) | ||
1572 | end) | ||
1573 | |||
1574 | lazy_teardown(function() | ||
1575 | os.remove(tmpname) | ||
1576 | end) | ||
1577 | |||
1578 | it("passes variables w/o spaces correctly", function() | ||
1579 | fs.execute_env({ | ||
1580 | FOO = "BAR", | ||
1581 | }, LUA, tmplua, tmpname) | ||
1582 | local data = readfile(tmpname) | ||
1583 | assert.same("BAR", data) | ||
1584 | end) | ||
1585 | |||
1586 | it("passes variables w/ spaces correctly", function() | ||
1587 | fs.execute_env({ | ||
1588 | FOO = "BAR with spaces", | ||
1589 | }, LUA, tmplua, tmpname) | ||
1590 | local data = readfile(tmpname) | ||
1591 | assert.same("BAR with spaces", data) | ||
1592 | end) | ||
1593 | end) | ||
1594 | |||
1544 | end) | 1595 | end) |