Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: some failing tests #855

Merged
merged 3 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.PHONY: test race cover robeaux examples test_with_coverage fmt_check

excluding_vendor := $(shell go list ./... | grep -v /vendor/)
# opencv platform currently skipped to prevent install of preconditions
including_except := $(shell go list ./... | grep -v platforms/opencv)

# Run tests on all non-vendor directories
# Run tests on nearly all directories
test:
go test -v $(excluding_vendor)
go test -v $(including_except)

# Run tests with race detection on all non-vendor directories
# Run tests with race detection
race:
go test -race $(excluding_vendor)
go test -race $(including_except)

# Check for code well-formedness
fmt_check:
Expand Down
4 changes: 2 additions & 2 deletions platforms/beaglebone/beaglebone_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ func TestBeagleboneAdaptor(t *testing.T) {
gobottest.Assert(t, a.ServoWrite("P9_99", 175), errors.New("Not a valid PWM pin"))

fs.WithReadError = true
gobottest.Assert(t, a.PwmWrite("P9_21", 175), errors.New("read error"))
gobottest.Assert(t, strings.Contains(a.PwmWrite("P9_21", 175).Error(), "read error"), true)
fs.WithReadError = false

fs.WithWriteError = true
gobottest.Assert(t, a.PwmWrite("P9_22", 175), errors.New("write error"))
gobottest.Assert(t, strings.Contains(a.PwmWrite("P9_22", 175).Error(), "write error"), true)
fs.WithWriteError = false

// Analog
Expand Down
4 changes: 2 additions & 2 deletions platforms/chip/chip_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ func TestAdaptorPwmWriteError(t *testing.T) {
fs.WithWriteError = true

err := a.PwmWrite("PWM0", 100)
gobottest.Assert(t, err, errors.New("write error"))
gobottest.Assert(t, strings.Contains(err.Error(), "write error"), true)
}

func TestAdaptorPwmReadError(t *testing.T) {
a, fs := initTestChipAdaptor()
fs.WithReadError = true

err := a.PwmWrite("PWM0", 100)
gobottest.Assert(t, err, errors.New("read error"))
gobottest.Assert(t, strings.Contains(err.Error(), "read error"), true)
}

func TestChipDefaultBus(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions platforms/intel-iot/edison/edison_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func TestAdaptorPwmWriteError(t *testing.T) {
fs.WithWriteError = true

err := a.PwmWrite("5", 100)
gobottest.Assert(t, err, errors.New("write error"))
gobottest.Assert(t, strings.Contains(err.Error(), "write error"), true)
}

func TestAdaptorPwmReadError(t *testing.T) {
Expand All @@ -488,7 +488,7 @@ func TestAdaptorPwmReadError(t *testing.T) {
fs.WithReadError = true

err := a.PwmWrite("5", 100)
gobottest.Assert(t, err, errors.New("read error"))
gobottest.Assert(t, strings.Contains(err.Error(), "read error"), true)
}

func TestAdaptorAnalog(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions platforms/keyboard/keyboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ func TestParseEscape(t *testing.T) {
}

func TestParseHyphen(t *testing.T) {
gobottest.Assert(t, Parse(bytes{45, 0, 0}).Key, Escape)
gobottest.Assert(t, Parse(bytes{45, 0, 0}).Key, Hyphen)
}

func TestParseAsterisk(t *testing.T) {
gobottest.Assert(t, Parse(bytes{42, 0, 0}).Key, Escape)
gobottest.Assert(t, Parse(bytes{42, 0, 0}).Key, Asterisk)
}

func TestParsePlus(t *testing.T) {
gobottest.Assert(t, Parse(bytes{43, 0, 0}).Key, Escape)
gobottest.Assert(t, Parse(bytes{43, 0, 0}).Key, Plus)
}

func TestParseSlash(t *testing.T) {
gobottest.Assert(t, Parse(bytes{47, 0, 0}).Key, Escape)
gobottest.Assert(t, Parse(bytes{47, 0, 0}).Key, Slash)
}

func TestParseDot(t *testing.T) {
gobottest.Assert(t, Parse(bytes{46, 0, 0}).Key, Escape)
gobottest.Assert(t, Parse(bytes{46, 0, 0}).Key, Dot)
}

func TestParseNotEscape(t *testing.T) {
Expand Down
7 changes: 6 additions & 1 deletion platforms/raspi/pwm_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func (p *PWMPin) Polarity() (polarity string, err error) {
return "normal", nil
}

// SetPolarity does not do anything when using PiBlaster
func (p *PWMPin) SetPolarity(value string) (err error) {
return nil
}

// InvertPolarity does not do anything when using PiBlaster
func (p *PWMPin) InvertPolarity(invert bool) (err error) {
return nil
Expand Down Expand Up @@ -83,7 +88,7 @@ func (p *PWMPin) SetDutyCycle(duty uint32) (err error) {
p.dc = duty

val := gobot.FromScale(float64(p.dc), 0, float64(p.period))

// never go below minimum allowed duty for pi blaster
// unless the duty equals to 0
if val < 0.05 && val != 0 {
Expand Down
4 changes: 2 additions & 2 deletions platforms/upboard/up2/adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ func TestUP2AdaptorPwmWriteError(t *testing.T) {
fs.WithWriteError = true

err := a.PwmWrite("32", 100)
gobottest.Assert(t, err, errors.New("write error"))
gobottest.Assert(t, strings.Contains(err.Error(), "write error"), true)
}

func TestUP2AdaptorPwmReadError(t *testing.T) {
a, fs := initTestUP2Adaptor()
fs.WithReadError = true

err := a.PwmWrite("32", 100)
gobottest.Assert(t, err, errors.New("read error"))
gobottest.Assert(t, strings.Contains(err.Error(), "read error"), true)
}

func TestUP2I2CDefaultBus(t *testing.T) {
Expand Down