• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ooni / probe-cli / 9389013168 / 1
72%
master: 72%

Build:
DEFAULT BRANCH: master
Ran 05 Jun 2024 06:08PM UTC
Files 555
Run time 12s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

05 Jun 2024 06:02PM UTC coverage: 83.203% (+0.01%) from 83.191%
9389013168.1

push

github

web-flow
fix(registry): instantiate factory for each invocation (#1614)

The current structure of the `*registry.Factory` registry is that we
register an experiment like this:

```Go
func init() {
	AllExperiments["dnscheck"] = &Factory{
		build: func(config interface{}) model.ExperimentMeasurer {
			return dnscheck.NewExperimentMeasurer(
				*config.(*dnscheck.Config),
			)
		},
		config:           &dnscheck.Config{},
		enabledByDefault: true,
		inputPolicy:      model.InputOrStaticDefault,
	}
}
```

Then, when we're setting options, we're modifying the `config` directly
with code like this:

```Go
// SetOptionAny sets an option given any value.
func (b *Factory) SetOptionAny(key string, value any) error {
	field, err := b.fieldbyname(b.config, key)
	if err != nil {
		return err
	}
	switch field.Kind() {
	case reflect.Int64:
		return b.setOptionInt(field, value)
	case reflect.Bool:
		return b.setOptionBool(field, value)
	case reflect.String:
		return b.setOptionString(field, value)
	default:
		return fmt.Errorf("%w: %T", ErrUnsupportedOptionType, value)
	}
}
```

Finally, we pass the modified config to a new experiment when we're
creating it:

```Go
func (b *Factory) NewExperimentMeasurer() model.ExperimentMeasurer {
	return b.build(b.config)
}
```

This means that, if we run two back experiments that both require
options, we're going to always reuse the same option structure. This
feels wrong. We should instead construct a new factory each time, so we
start from empty options:

```Go
func init() {
	AllExperiments["dnscheck"] = func() *Factory {
		return &Factory{
			build: func(config interface{}) model.ExperimentMeasurer {
				return dnscheck.NewExperimentMeasurer(
					*config.(*dnscheck.Config),
				)
			},
			config:           &dnscheck.Config{},
			enabledByDefault: true,
			inputPolicy:      model.InputOrStaticDefault,
		}
	}
}
```

This diff applies this very simple mechanical chan... (continued)

26996 of 32446 relevant lines covered (83.2%)

54.6 hits per line

Source Files on job 0 - 9389013168.1
  • Tree
  • List 0
  • Changed 59
  • Source Changed 0
  • Coverage Changed 35
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 9389013168
  • 15dac36f on github
  • Prev Job for on master (#9388705026.1)
  • Next Job for on master (#9398282438.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc