194 lines · 5.3 KB
// Package app starts the application under test and stops it again.
//
// Everything here is shell commands and an HTTP poll, because that is the
// only interface every application already has. squint never links against
// the thing it photographs.
package app

import (
	"context"
	"fmt"
	"io"
	"net"
	"net/http"
	"os"
	"os/exec"
	"path/filepath"
	"syscall"
	"time"

	"git.mills.io/prologic/squint/internal/config"
)

// Instance is a running application: where it lives on disk, what address
// it answers on, and the process to kill when the shoot is over.
type Instance struct {
	BaseURL string
	Port    int
	Dir     string

	cmd    *exec.Cmd
	tmp    string
	log    *os.File
	cancel context.CancelFunc
}

// Options are what Start needs beyond the config.
type Options struct {
	// Dir is the checkout to build and run in. For a candidate this is
	// the working tree; for a baseline it is a git worktree.
	Dir string