File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,13 @@ func TestInitialization(testRoot string) {
4848func ClearToolchainRegistration () {
4949 // Unset environment variables
5050 systemEnvVars := os .Environ ()
51- pattern := regexp .MustCompile (`(\w+)_TOOLCHAIN_(\d+)_(\d+)_(\d+)=(.*)` )
51+ pattern := regexp .MustCompile (`(( \w+)_TOOLCHAIN_(\d+)_(\d+)_(\d+) )=(.*)` )
5252 for _ , systemEnvVar := range systemEnvVars {
5353 matched := pattern .FindAllStringSubmatch (systemEnvVar , - 1 )
5454 if matched == nil {
5555 continue
5656 }
57- os .Unsetenv (systemEnvVar )
57+ os .Unsetenv (matched [ 0 ][ 1 ] )
5858 }
5959}
6060
Original file line number Diff line number Diff line change @@ -119,6 +119,10 @@ func (m *Maker) ProcessToolchain() error {
119119 registeredVersions = append (registeredVersions , version )
120120 }
121121 }
122+ if len (registeredVersions ) == 0 {
123+ err := errors .New ("compiler registration environment variable missing, format: " + contextToolchain + "_TOOLCHAIN_<major>_<minor>_<patch>" )
124+ return err
125+ }
122126 sort .Sort (sort .Reverse (semver .Collection (registeredVersions )))
123127
124128 // Get latest compatible registered version
Original file line number Diff line number Diff line change @@ -23,9 +23,20 @@ func TestToolchain(t *testing.T) {
2323 assert := assert .New (t )
2424 var m maker.Maker
2525
26- // Update environment variables
26+ // Clear environment variables
2727 m .EnvVars = utils .UpdateEnvVars (m .InstallConfigs .BinPath , m .InstallConfigs .EtcPath )
2828 inittest .ClearToolchainRegistration ()
29+
30+ t .Run ("test missing environment variables" , func (t * testing.T ) {
31+ inittest .ClearToolchainRegistration ()
32+ m .Cbuilds = make ([]maker.Cbuild , 1 )
33+ m .Cbuilds [0 ].BuildDescType .Compiler = "AC6@>=6.22.0"
34+ err := m .ProcessToolchain ()
35+ assert .Error (err )
36+ assert .ErrorContains (err , "compiler registration environment variable missing, format: AC6_TOOLCHAIN_<major>_<minor>_<patch>" )
37+ })
38+
39+ // Update environment variables
2940 absTestRoot , _ := filepath .Abs (testRoot )
3041 absTestRoot = filepath .ToSlash (absTestRoot )
3142 os .Setenv ("AC6_TOOLCHAIN_6_19_0" , path .Join (absTestRoot , "run/path/to/ac619/bin" ))
You can’t perform that action at this time.
0 commit comments