<commit_before>package run

import (
	"fmt"
	"syscall"
	"testing"

	"github.com/anonx/sunplate/command"
)

func TestExecute_IncorrectTask(t *testing.T) {
	ts := []string{
		"gxgbhsjdjdduuhdhsh", // This is expected to cause a panic.
	}
	defer expectPanic(fmt.Sprintf(`Command "%s" does not exist. Panic expected.`, ts[0]))
	execute(ts)
}

func TestExecute(t *testing.T) {
	ts := []string{
		passCommand,
		`sunplate echo "Hello, world!"`,
		`sunplate echo "This is test"`,
	}
	execute(ts)
}

func TestUserCommand(t *testing.T) {
	imp := "github.com/anonx/sunplate/skeleton"
	res := userCommand(":application", imp)
	exp := "skeleton"
	if res != exp {
		t.Errorf("Incorrect user command. Expected `%s`, got `%s`.", exp, res)
	}
}

func TestRun_IncorrectTask(t *testing.T) {
	c := "gxgbhsjdjdduuhdhsh"
	defer expectPanic(fmt.Sprintf(`Command "%s" does not exist. Panic expected.`, c))
	run(c)
}

func TestRun(t *testing.T) {
	run("sleep 10")
	cmd := run("sleep 1") // Starting a new instance.
	err := cmd.Wait()
	if err != nil {
		t.Error("Command is not started at the time of check.")
	}
}

func TestStart_EmptyFile(t *testing.T) {
	notify <- syscall.SIGTERM
	start("run", command.Data{
		"run": "github.com/anonx/sunplate/run/testdata/empty",
	})
}

func TestStart(t *testing.T) {
	defer expectPanic("Application has been killed, panic expected.")
	notify <- syscall.SIGTERM
	start("run", command.Data{
		"run": "github.com/anonx/sunplate/run/testdata/nonempty",
	})
}

func TestRebuildFunc(t *testing.T) {<commit_msg>Replaced sleep in run_tests for cross platform support<commit_after>package run

import (
	"fmt"
	"syscall"
	"testing"

	"github.com/anonx/sunplate/command"
)

func TestExecute_IncorrectTask(t *testing.T) {
	ts := []string{
		"gxgbhsjdjdduuhdhsh", // This is expected to cause a panic.
	}
	defer expectPanic(fmt.Sprintf(`Command "%s" does not exist. Panic expected.`, ts[0]))
	execute(ts)
}

func TestExecute(t *testing.T) {
	ts := []string{
		passCommand,
		`sunplate echo "Hello, world!"`,
		`sunplate echo "This is test"`,
	}
	execute(ts)
}

func TestUserCommand(t *testing.T) {
	imp := "github.com/anonx/sunplate/skeleton"
	res := userCommand(":application", imp)
	exp := "skeleton"
	if res != exp {
		t.Errorf("Incorrect user command. Expected `%s`, got `%s`.", exp, res)
	}
}

func TestRun_IncorrectTask(t *testing.T) {
	c := "gxgbhsjdjdduuhdhsh"
	defer expectPanic(fmt.Sprintf(`Command "%s" does not exist. Panic expected.`, c))
	run(c)
}

func TestRun(t *testing.T) {
	run("sunplate run github.com/anonx/sunplate/skeleton") // A program that runs forever.
	cmd := run(`sunplate echo "Starting a new instance"`)  // This should kill the previous instance.
	err := cmd.Wait()
	if err != nil {
		t.Error("Command is not started at the time of check.")
	}
}

func TestStart_EmptyFile(t *testing.T) {
	notify <- syscall.SIGTERM
	start("run", command.Data{
		"run": "github.com/anonx/sunplate/run/testdata/empty",
	})
}

func TestStart(t *testing.T) {
	defer expectPanic("Application has been killed, panic expected.")
	notify <- syscall.SIGTERM
	start("run", command.Data{
		"run": "github.com/anonx/sunplate/run/testdata/nonempty",
	})
}

func TestRebuildFunc(t *testing.T) {
{'fraction_non_alphanumeric': 0.1610381488430269, 'fraction_numerical': 0.0015634771732332708, 'mean_word_length': 4.340567612687813, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '570138', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1190, 'n_words': 293}