Example #1
0
func (b *Builder) Test(p *pkg.LocalPackage) error {
	// Build the packages alphabetically to ensure a consistent order.
	bpkgs := b.sortedBuildPackages()
	for _, bpkg := range bpkgs {
		if err := b.buildPackage(bpkg); err != nil {
			return err
		}
	}

	testBpkg := b.PkgMap[p]
	testFilename := b.TestExePath(testBpkg)
	if err := b.link(testFilename, nil, nil); err != nil {
		return err
	}

	// Run the tests.
	if err := os.Chdir(filepath.Dir(testFilename)); err != nil {
		return err
	}

	util.StatusMessage(util.VERBOSITY_DEFAULT, "Executing test: %s\n",
		testFilename)
	if _, err := util.ShellCommand(testFilename); err != nil {
		newtError := err.(*util.NewtError)
		newtError.Text = fmt.Sprintf("Test failure (%s):\n%s", p.Name(),
			newtError.Text)
		return newtError
	}

	return nil
}
Example #2
0
func (cfg *Cfg) readDefsOnce(lpkg *pkg.LocalPackage,
	features map[string]bool) error {
	v := lpkg.SyscfgV

	lfeatures := cfg.FeaturesForLpkg(lpkg)
	for k, _ := range features {
		lfeatures[k] = true
	}

	settings := newtutil.GetStringMapFeatures(v, lfeatures, "syscfg.defs")
	if settings != nil {
		for k, v := range settings {
			vals := v.(map[interface{}]interface{})
			entry, err := readSetting(k, lpkg, vals)
			if err != nil {
				return util.FmtNewtError("Config for package %s: %s",
					lpkg.Name(), err.Error())
			}

			if _, exists := cfg.Settings[k]; exists {
				// XXX: Better error message.
				return util.FmtNewtError("setting %s redefined", k)
			}
			cfg.Settings[k] = entry
		}
	}

	return nil
}
Example #3
0
func (cfg *Cfg) FeaturesForLpkg(lpkg *pkg.LocalPackage) map[string]bool {
	features := cfg.Features()

	for k, v := range lpkg.InjectedSettings() {
		_, ok := features[k]
		if ok {
			log.Warnf("Attempt to override syscfg setting %s with "+
				"injected feature from package %s", k, lpkg.Name())
		} else {
			if ValueIsTrue(v) {
				features[k] = true
			}
		}
	}

	return features
}
Example #4
0
func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
	features map[string]bool) error {
	v := lpkg.SyscfgV

	lfeatures := cfg.FeaturesForLpkg(lpkg)
	for k, _ := range features {
		lfeatures[k] = true
	}

	values := newtutil.GetStringMapFeatures(v, lfeatures, "syscfg.vals")
	for k, v := range values {
		if normalizePkgType(lpkg.Type()) == pkg.PACKAGE_TYPE_LIB {
			// A library package is overriding a setting; this is disallowed.
			// Overrides must come from a higher priority package.
			lateral := CfgLateral{
				PkgName:     lpkg.Name(),
				SettingName: k,
			}
			cfg.Laterals = append(cfg.Laterals, lateral)
		} else {
			entry, ok := cfg.Settings[k]
			if ok {
				entry.appendValue(lpkg, v)
				cfg.Settings[k] = entry
			} else {
				orphan := CfgPoint{
					Value:  stringValue(v),
					Source: lpkg,
				}
				cfg.Orphans[k] = append(cfg.Orphans[k], orphan)
			}
		}
	}

	return nil
}