Skip to content

Commit f68b66e

Browse files
committed
tests: attempt to get windows fixed
1 parent cb2d683 commit f68b66e

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ jobs:
1515
- os: ubuntu-22.04-arm
1616
deps: sudo apt-get install -y cmake libssl-dev
1717
- os: windows-latest
18-
deps: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
1918
- os: windows-11-arm
20-
deps: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
2119

2220
runs-on: ${{ matrix.os }}
2321

@@ -26,9 +24,14 @@ jobs:
2624
with:
2725
submodules: recursive
2826

29-
- name: Install dependencies
27+
- name: Install dependencies (Linux)
28+
if: matrix.deps != ''
3029
run: ${{ matrix.deps }}
3130

31+
- name: Setup cmake (Windows ARM64)
32+
if: matrix.os == 'windows-11-arm'
33+
uses: jwlawson/actions-setup-cmake@v2
34+
3235
- name: Setup lde
3336
uses: lde-org/setup-lde@master
3437
with:

tests/git2.test.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
local test = require("lde-test")
22
local git2 = require("git2-sys")
33

4-
local tmpBase = os.tmpname()
5-
os.remove(tmpBase)
4+
local sep = string.sub(package.config, 1, 1)
5+
local isWindows = sep == "\\"
6+
7+
local tmpBase = (os.getenv("TEMP") or os.getenv("TMPDIR") or "/tmp") .. sep .. "git2-sys-test-" .. tostring(os.time())
68

79
local function mkTmp(suffix)
810
local dir = tmpBase .. suffix
9-
os.execute('mkdir -p "' .. dir .. '"')
11+
if isWindows then
12+
os.execute('mkdir "' .. dir .. '"')
13+
else
14+
os.execute('mkdir -p "' .. dir .. '"')
15+
end
1016
return dir
1117
end
1218

1319
local function mkCommit(dir, msg)
20+
local touch = isWindows and ('type nul > "' .. dir .. sep .. 'f"') or ('touch "' .. dir .. '/f"')
1421
os.execute('git -C "' .. dir .. '" init')
1522
os.execute('git -C "' .. dir .. '" config user.email "t@t.com"')
1623
os.execute('git -C "' .. dir .. '" config user.name "T"')
17-
os.execute('touch "' .. dir .. '/f"')
24+
os.execute(touch)
1825
os.execute('git -C "' .. dir .. '" add f')
1926
os.execute('git -C "' .. dir .. '" commit -m "' .. msg .. '"')
2027
end
@@ -47,21 +54,14 @@ end)
4754

4855
test.it("commitLookup returns correct metadata", function()
4956
local dir = mkTmp("meta")
50-
os.execute('git -C "' .. dir .. '" init || true')
51-
os.execute('mkdir -p "' .. dir .. '"')
52-
os.execute('git -C "' .. dir .. '" init')
53-
os.execute('git -C "' .. dir .. '" config user.email "a@b.com"')
54-
os.execute('git -C "' .. dir .. '" config user.name "Alice"')
55-
os.execute('touch "' .. dir .. '/f"')
56-
os.execute('git -C "' .. dir .. '" add f')
57-
os.execute('git -C "' .. dir .. '" commit -m "hello world"')
57+
mkCommit(dir, "hello world")
5858
local repo = git2.open(dir)
5959
local sha = repo.head()
6060
local c = repo.commitLookup(sha)
6161
test.equal(c.id, sha)
6262
test.truthy(c.summary:find("hello world"))
63-
test.equal(c.author.name, "Alice")
64-
test.equal(c.author.email, "a@b.com")
63+
test.equal(c.author.name, "T")
64+
test.equal(c.author.email, "t@t.com")
6565
test.truthy(c.time > 0)
6666
end)
6767

0 commit comments

Comments
 (0)