pulumi/pkg/ast/refs_test.go

236 lines
7.6 KiB
Go
Raw Normal View History

Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
// Copyright 2016 Marapongo, Inc. All rights reserved.
package ast
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRefParse(t *testing.T) {
{
s := "simple"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := string("simple@" + DefaultRefVersion)
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "simple@1.0.6"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
}
{
s := "simple@>=1.0.6"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
}
{
s := "simple@6f99088"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("6f99088"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("6f99088"), p.Version)
}
{
s := "simple@83030685c3b8a3dbe96bd10ab055f029667a96b0"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "simple", string(p.Name))
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
}
{
s := "namespace/complex"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "namespace/complex", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "namespace/complex", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "ns1/ns2/ns3/ns4/complex"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "_/_/_/_/a0/c0Mpl3x_"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "", p.Base)
assert.Equal(t, "_/_/_/_/a0/c0Mpl3x_", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, DefaultRefBase, p.Base)
assert.Equal(t, "_/_/_/_/a0/c0Mpl3x_", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "github.com/ns1/ns2/ns3/ns4/complex"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, DefaultRefProto, p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "git://github.com/ns1/ns2/ns3/ns4/complex"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, "", string(p.Version))
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, DefaultRefVersion, p.Version)
}
{
s := "git://github.com/ns1/ns2/ns3/ns4/complex@1.0.6"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, VersionSpec("1.0.6"), p.Version)
}
{
s := "git://github.com/ns1/ns2/ns3/ns4/complex@>=1.0.6"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, s, p.String())
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, VersionSpec(">=1.0.6"), p.Version)
p = p.Defaults()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, ">=1.0.6", string(p.Version))
}
{
s := "git://github.com/ns1/ns2/ns3/ns4/complex@6f99088"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, VersionSpec("6f99088"), p.Version)
p = p.Defaults()
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, "6f99088", string(p.Version))
}
{
s := "git://github.com/ns1/ns2/ns3/ns4/complex@83030685c3b8a3dbe96bd10ab055f029667a96b0"
p, err := Ref(s).Parse()
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Nil(t, err)
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
assert.Equal(t, VersionSpec("83030685c3b8a3dbe96bd10ab055f029667a96b0"), p.Version)
p = p.Defaults()
assert.Equal(t, "git://", p.Proto)
assert.Equal(t, "github.com/", p.Base)
assert.Equal(t, "ns1/ns2/ns3/ns4/complex", string(p.Name))
Implement dependency versions This change implements dependency versions, including semantic analysis, per the checkin https://github.com/marapongo/mu/commit/83030685c3b8a3dbe96bd10ab055f029667a96b0. There's quite a bit in here but at a top-level this parses and validates dependency references of the form [[proto://]base.url]namespace/.../name[@version] and verifies that the components are correct, as well as binding them to symbols. These references can appear in two places at the moment: * Service types. * Cluster dependencies. As part of this change, a number of supporting changes have been made: * Parse Workspaces using a full-blown parser, parser analysis, and semantic analysis. This allows us to share logic around the validation of common AST types. This also moves some of the logic around loading workspace.yaml files back to the parser, where it can be unified with the way we load Mu.yaml files. * New ast.Version and ast.VersionSpec types. The former represents a precise version -- either a specific semantic version or a short or long Git SHA hash -- and the latter represents a range -- either a Version, "latest", or a semantic range. * New ast.Ref and ast.RefParts types. The former is an unparsed string that is thought to contain a Ref, while the latter is a validated Ref that has been parsed into its components (Proto, Base, Name, and Version). * Added some type assertions to ensure certain structs implement certain interfaces, to speed up finding errors. (And remove the coercions that zero-fill vtbl slots.) * Be consistent about prefixing error types with Error or Warning. * Organize the core compiler driver's logic into three methods, FE, sema, and BE. * A bunch of tests for some of the above ... more to come in an upcoming change.
2016-11-23 01:58:23 +01:00
assert.Equal(t, "83030685c3b8a3dbe96bd10ab055f029667a96b0", string(p.Version))
}
}