Skip to content

Commit f278eac

Browse files
committed
tests: download .bsp on run
1 parent d87b1a1 commit f278eac

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.bsp

pkg/bsptracer/bsptracer_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package bsptracer_test
22

33
import (
4+
"log"
45
"os"
6+
"os/exec"
57
"testing"
68

79
"github.com/go-gl/mathgl/mgl32"
@@ -10,6 +12,17 @@ import (
1012
"github.com/saiko-tech/bsp-tracer/pkg/bsptracer"
1113
)
1214

15+
func TestMain(m *testing.M) {
16+
log.Println("downloading testdata ...")
17+
18+
err := exec.Command("../../testdata/download.sh").Run()
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
os.Exit(m.Run())
24+
}
25+
1326
// expects CS:GO to be installed in "$HOME/games/SteamLibrary/steamapps/common/Counter-Strike Global Offensive"
1427
func csgoDir(tb testing.TB) string {
1528
tb.Helper()

pkg/bsptracer/static_props.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,18 @@ func staticPropsByLeaf(bspfile *bsp.Bsp, models []*studiomodel.StudioModel) map[
7373

7474
for _, i := range leafIndices {
7575
model := models[p.GetPropType()]
76+
77+
var tris [][3]mgl32.Vec3
78+
79+
// missing model
80+
if model != nil {
81+
tris = triangles(p, model.Phy)
82+
}
83+
7684
res[i] = append(res[i], staticProp{
7785
prop: p,
7886
model: model,
79-
triangles: triangles(p, model.Phy),
87+
triangles: tris,
8088
})
8189
}
8290
}

testdata/download.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cd $(dirname $0)
4+
5+
git cat-file blob testdata:testdata/de_cache.bsp | git lfs smudge > de_cache.bsp

0 commit comments

Comments
 (0)