<commit_before><commit_msg>Godo install and test tasks<commit_after>package main

import (
    do "gopkg.in/godo.v2"
)

const packageRoot = "functorama.com/demo"

var toolkit = []string{
    "base",
    "draw",
    "sequence",
    "region",
    "sharedregion",
}

var nativeArithmetic = []string{
    "nativebase",
    "nativesequence",
    "nativeregion",
    "nativesharedregion",
}

var bigArithmetic = []string{
   "bigbase",
   "bigsequence",
   "bigregion",
   "bigsharedregion",
}

var appBase = []string {
    "libgodelbrot",
}

var apps = []string{
    "configbrot",
    "renderbrot",
    "godelbrot",
    "webdelbrot",
    "autobrot",
}

var all []string

// Group all packages in one slice
func init() {
    subsystems := [][]string{
        toolkit,
        nativeArithmetic,
        bigArithmetic,
        appBase,
        apps,
    }
    for _, sub := range subsystems {
        all = append(all, sub...)
    }
}

func tasks(p *do.Project) {
    units := map[string][]string{
        "toolkit": toolkit,
        "native": nativeArithmetic,
        "big": bigArithmetic,
        "appBase": appBase,
        "apps": apps,
        "all": all,
    }
    // Install/Test for each subsystem
    for subsystem, components := range units {
        buildFeatures(p, subsystem, components)
    }
    // Default task is install all
    p.Task("default", do.S{"allInstall"}, nil)
}

func buildFeatures(p *do.Project, subsystem string, components []string) {
    var componentsInstall do.S
    var componentsTest do.S
    for _, module := range components {
        install := installTaskName(module)
        test := testTaskName(module)
        componentsInstall = append(componentsInstall, install)
        componentsTest = append(componentsTest, test)

        p.Task(install, nil, func(unit string) func(c *do.Context) {
            return func (c *do.Context) {
                goInstall(c, unit)
            }
        }(module))
        p.Task(test, nil, func(unit string) func(c *do.Context) {
             return func (c *do.Context) {
                goTest(c, unit)
            }
        }(module))
    }

    p.Task(installTaskName(subsystem), componentsInstall, nil)
    p.Task(testTaskName(subsystem), componentsTest, nil)
}

func goInstall(c *do.Context, unit string) {
    command := "go install " + fullUnitPath(unit)
    c.Run(command)
}

func goTest(c *do.Context, unit string) {
    command := "go test " + fullUnitPath(unit)
    c.Run(command)
}

func fullUnitPath(module string) string {
    return packageRoot + "/" + module
}

func installTaskName(module string) string {
    return module + "Install"
}

func testTaskName(module string) string {
    return module + "Test"
}

func main() {
    do.Godo(tasks)
}
{'fraction_non_alphanumeric': 0.13016453382084095, 'fraction_numerical': 0.00036563071297989033, 'mean_word_length': 2.590551181102362, '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': '1822472', 'n_tokens_mistral': 884, 'n_tokens_neox': 863, 'n_words': 211}