go-openapi / spec

openapi specification object model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test failure under Go 1.13

eclipseo opened this issue · comments

Latest spec with Go 1.13:

Testing    in: /builddir/build/BUILD/spec-0.19.2/_build/src
         PATH: /builddir/build/BUILD/spec-0.19.2/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/spec-0.19.2/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags "-X github.com/go-openapi/spec/version=0.19.2 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '"
      testing: github.com/go-openapi/spec
github.com/go-openapi/spec
--- FAIL: Test_ExpandSwaggerSchema (0.03s)
    expander_test.go:667: 
        	Error Trace:	expander_test.go:667
        	            				expander_test.go:665
        	            				expander_test.go:633
        	Error:      	Received unexpected error:
        	            	object has no key "default"
        	Test:       	Test_ExpandSwaggerSchema
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/default"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/description"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/type"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/title"
    expander_test.go:639: 
        	Error Trace:	expander_test.go:639
        	Error:      	Should be true
        	Test:       	Test_ExpandSwaggerSchema
        	Messages:   	expected $ref to be inlined, got: "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
FAIL
exit status 1
FAIL	github.com/go-openapi/spec	2.815s

That's not released yet right?

Beta 1 is available for testing. It is currently used in Fedora Rawhide mass rebuild.

I believe the problem is that 1.13 has added a reflect.Value.IsZero method (https://tip.golang.org/doc/go1.13#reflect). This slightly changes the behavior of the swag.IsZero function for floating-point, struct, array, and unsafe.Pointer types. That seems the most likely cause of the problem.

Actually, that's not quite it. I don't think the code makes sense.

The code at https://github.com/go-openapi/jsonpointer/blob/master/pointer.go#L138 calls swag.IsZero(mv). But mv is a reflect.Value. So this code was asking whether the reflect.Value value was zero, which was never true. In Go 1.13, reflect.Value has an IsZero method, so now swag.IsZero would call that method to discover whether the value stored in the reflect.Value is zero. That is a different question. Either way, it doesn't make sense to call swig.IsZero(mv).