aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/browser_options_resize_test.go (955B)


      1 package main
      2 
      3 import (
      4 	"context"
      5 	"net/http/httptest"
      6 	"os"
      7 	"os/exec"
      8 	"path/filepath"
      9 	"runtime"
     10 	"testing"
     11 	"time"
     12 )
     13 
     14 func TestBrowserOptionsResize(t *testing.T) {
     15 	if os.Getenv("AO_GAME_TEST") != "1" {
     16 		t.Skip("set AO_GAME_TEST=1 for native Options resizing")
     17 	}
     18 	_, source, _, _ := runtime.Caller(0)
     19 	root := filepath.Dir(filepath.Dir(source))
     20 	output := filepath.Join(root, "local/options-resize", time.Now().Format("20060102-150405"))
     21 	world := newTestServer(t)
     22 	startTestService(t, world)
     23 	host := httptest.NewServer(world.httpHandler())
     24 	defer host.Close()
     25 	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
     26 	defer cancel()
     27 	command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_options_resize.mjs"), host.URL, output)
     28 	command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
     29 	err := command.Run()
     30 	t.Logf("Browser artifacts: %s", output)
     31 	if err != nil {
     32 		t.Fatal(err)
     33 	}
     34 }