<commit_before>package adapter

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/cookiejar"
	"os"
	"os/exec"
	"path/filepath"
	"syscall"
	"testing"
	"time"
)

func testStartH2O() (*exec.Cmd, error) {
	wd, _ := os.Getwd()
	os.Chdir(filepath.Join(wd, "examples", "h2o"))
	cmd := exec.Command("h2o", "-c", "h2o.conf")
	cmd.Stdout = os.Stderr
	cmd.Stderr = os.Stderr
	return cmd, cmd.Start()
}

func testStopH2O(cmd *exec.Cmd) {
	cmd.Process.Signal(syscall.SIGTERM)
	cmd.Wait()
}

func TestH2O(t *testing.T) {
	if os.Getenv("CI") == "" {
		t.Log("SKIP in not CI environment. if you want this test, execute `CI=1 go test .`.")
		return
	}
	h2o, err := testStartH2O()
	if err != nil {
		t.Error(err)
		return
	}
	defer testStopH2O(h2o)
	fmt.Fprintln(os.Stderr, "start h2o")

	// wait for h2o is ready
	time.Sleep(time.Second)
	fmt.Fprintln(os.Stderr, "awake")

	c := NewConfig()
	c.Providers = map[string]map[string]interface{}{
		"development": map[string]interface{}{},
	}
	s, err := NewServer(*c)
	if err != nil {
		t.Error(err)
		return
	}
	go http.ListenAndServe(":18081", s)

	go http.ListenAndServe(":18082", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello, client")
	}))

	jar, _ := cookiejar.New(nil)
	client := http.Client{
		Jar: jar,

		// Note:
		// it takes a long time to shutdown gracefully when keep-alives is enabled.
		Transport: &http.Transport{DisableKeepAlives: true},
	}<commit_msg>reset working directory<commit_after>package adapter

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/cookiejar"
	"os"
	"os/exec"
	"path/filepath"
	"syscall"
	"testing"
	"time"
)

func testStartH2O() (*exec.Cmd, error) {
	wd, _ := os.Getwd()
	os.Chdir(filepath.Join(wd, "examples", "h2o"))
	defer os.Chdir(wd)
	cmd := exec.Command("h2o", "-c", "h2o.conf")
	cmd.Stdout = os.Stderr
	cmd.Stderr = os.Stderr
	return cmd, cmd.Start()
}

func testStopH2O(cmd *exec.Cmd) {
	cmd.Process.Signal(syscall.SIGTERM)
	cmd.Wait()
}

func TestH2O(t *testing.T) {
	if os.Getenv("CI") == "" {
		t.Log("SKIP in not CI environment. if you want this test, execute `CI=1 go test .`.")
		return
	}
	h2o, err := testStartH2O()
	if err != nil {
		t.Error(err)
		return
	}
	defer testStopH2O(h2o)
	fmt.Fprintln(os.Stderr, "start h2o")

	// wait for h2o is ready
	time.Sleep(time.Second)
	fmt.Fprintln(os.Stderr, "awake")

	c := NewConfig()
	c.Providers = map[string]map[string]interface{}{
		"development": map[string]interface{}{},
	}
	s, err := NewServer(*c)
	if err != nil {
		t.Error(err)
		return
	}
	go http.ListenAndServe(":18081", s)

	go http.ListenAndServe(":18082", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		r.Header.Get("")
		fmt.Fprintln(w, "Hello, client")
	}))

	jar, _ := cookiejar.New(nil)
	client := http.Client{
		Jar: jar,

		// Note:
		// it takes a long time to shutdown gracefully when keep-alives is enabled.
		Transport: &http.Transport{DisableKeepAlives: true},
	}
{'fraction_non_alphanumeric': 0.17683134582623508, 'fraction_numerical': 0.015672913117546847, 'mean_word_length': 3.942760942760943, 'pattern_counts': {'":': 6, '<': 3, '<?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': '7207720', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1220, 'n_words': 259}