コード例 #1
0
func pkgToUnitTests(pack *pkg.LocalPackage) []*pkg.LocalPackage {
	// If the user specified a unittest package, just test that one.
	if pack.Type() == pkg.PACKAGE_TYPE_UNITTEST {
		return []*pkg.LocalPackage{pack}
	}

	// Otherwise, return all the package's direct descendants that are unit
	// test packages.
	result := []*pkg.LocalPackage{}
	srcPath := pack.BasePath()
	for p, _ := range testablePkgs() {
		if p.Type() == pkg.PACKAGE_TYPE_UNITTEST &&
			filepath.Dir(p.BasePath()) == srcPath {

			result = append(result, p)
		}
	}

	return result
}
コード例 #2
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
}