예제 #1
0
// Generate an environment using it's manifest
func (em *envManifest) GenerateEnvironment(v bool, prompt string) error {
	// install go version if it's not installed yet
	if !LookupInstalledVersion(em.GoVersion) {
		if err := cache.CacheDownloadGit(em.GoVersion); err != nil {
			return err
		}
		if err := cache.Compile(em.GoVersion, v, false); err != nil {
			return err
		}
	}
	if prompt == "" {
		prompt = fmt.Sprintf("[%s]", em.Name)
	}
	impEnv := NewEnvironment(em.Name, prompt)
	if err := impEnv.Generate(); err != nil {
		os.RemoveAll(filepath.Join(os.Getenv("VENGO_HOME"), em.Name))
		return err
	}
	if err := impEnv.Install(em.GoVersion); err != nil {
		os.RemoveAll(filepath.Join(os.Getenv("VENGO_HOME"), em.Name))
		return err
	}
	impEnv.activate()
	defer impEnv.deactivate()
	if err := em.installPackages(v); err != nil {
		os.RemoveAll(filepath.Join(os.Getenv("VENGO_HOME"), em.Name))
		return err
	}
	return nil
}
예제 #2
0
파일: install.go 프로젝트: jmartiuk5/VenGO
// install from github source
func (i *Install) fromGit() (string, error) {
	if err := cache.CacheDownloadGit(i.Version, i.Force); err != nil {
		return "error while installing from github", err
	}
	if err := cache.Compile(i.Version, i.Verbose, i.NoCGO, i.BootStrap); err != nil {
		return "error while compiling from github", err
	}

	result := fmt.Sprintf(
		"%s", utils.Ok(fmt.Sprintf("Go %s installed", i.Version)))
	return result, nil
}
예제 #3
0
파일: env_test.go 프로젝트: jmartiuk5/VenGO
				goPath := fmt.Sprintf(`GOPATH="%s"`, e.VenGO_PATH)
				ps1 := fmt.Sprintf(`PS1="%s ${_VENGO_PREV_PS1}"`, e.PS1)

				Expect(byteLines[53]).To(Equal([]byte(vengoPath)))
				Expect(byteLines[73]).To(Equal([]byte(goRoot)))
				Expect(byteLines[83]).To(Equal([]byte(sysPath)))
				Expect(byteLines[76]).To(Equal([]byte(goTooldir)))
				Expect(byteLines[79]).To(Equal([]byte(goPath)))
				Expect(byteLines[86]).To(Equal([]byte(ps1)))
				os.RemoveAll(e.VenGO_PATH)
			})
		})

		Describe("Install", func() {
			It("Will create a symboolic link into VenGO_PATH", func() {
				Expect(cache.CacheDownloadGit("1.3.2")).To(Succeed())

				name := "goTest"
				prompt := "(gotest)"
				e := env.NewEnvironment(name, prompt)
				err := e.Generate()

				Expect(err).ToNot(HaveOccurred())
				Expect(e.Install("1.3.2")).To(Succeed())
				os.RemoveAll(filepath.Join(cache.CacheDirectory(), "go1.3.2"))
			})
		})
	}

	Describe("NewPackage", func() {
		It("Will return a configured package", func() {
예제 #4
0
				})
			})

			Context("Passing a directory that exists", func() {
				It("Should return true", func() {
					exists, err := cache.SourceExists(path.Base(dirName))
					Expect(err).ToNot(HaveOccurred())
					Expect(exists).To(BeTrue())
				})
			})
		})

		Describe("CacheDonwloadGit works as expected", func() {
			Context("Passing a non valid Go version", func() {
				It("Should fail and give back a descriptive error", func() {
					err := cache.CacheDownloadGit("20.0")
					Expect(err).To(HaveOccurred())
					Expect(err).To(Equal(fmt.Errorf(
						"20.0 doesn't seems to be a valid Go release\n"),
					))
				})
			})

			Context("Passing a valid Go version", func() {
				It("Should clone it into the cache directory", func() {
					err := cache.CacheDownloadGit("go1.1")
					Expect(err).ToNot(HaveOccurred())
					_, err = os.Stat(filepath.Join(cache.CacheDirectory(), "go1.1"))
					Expect(err).NotTo(HaveOccurred())
					os.RemoveAll(filepath.Join(cache.CacheDirectory(), "go1.1"))
					debug.FreeOSMemory()