示例#1
0
文件: runner.go 项目: jean/gauge
// Looks for a runner configuration inside the runner directory
// finds the runner configuration matching to the manifest and executes the commands for the current OS
func startRunner(manifest *manifest.Manifest, port string, reporter reporter.Reporter, killChannel chan bool) (*TestRunner, error) {
	var r Runner
	runnerDir, err := getLanguageJSONFilePath(manifest, &r)
	if err != nil {
		return nil, err
	}
	compatibilityErr := version.CheckCompatibility(version.CurrentGaugeVersion, &r.GaugeVersionSupport)
	if compatibilityErr != nil {
		return nil, fmt.Errorf("Compatibility error. %s", compatibilityErr.Error())
	}
	command := getOsSpecificCommand(r)
	env := getCleanEnv(port, os.Environ())
	cmd, err := common.ExecuteCommandWithEnv(command, runnerDir, reporter, reporter, env)
	if err != nil {
		return nil, err
	}
	go func() {
		select {
		case <-killChannel:
			cmd.Process.Kill()
		}
	}()
	// Wait for the process to exit so we will get a detailed error message
	errChannel := make(chan error)
	testRunner := &TestRunner{Cmd: cmd, ErrorChannel: errChannel, mutex: &sync.Mutex{}}
	testRunner.waitAndGetErrorMessage()
	return testRunner, nil
}
示例#2
0
文件: runner.go 项目: krwhitney/gauge
// Looks for a runner configuration inside the runner directory
// finds the runner configuration matching to the manifest and executes the commands for the current OS
func startRunner(manifest *manifest.Manifest, port string, log *logger.GaugeLogger, killChannel chan bool) (*TestRunner, error) {
	var r Runner
	runnerDir, err := getLanguageJSONFilePath(manifest, &r)
	if err != nil {
		return nil, err
	}
	compatibilityErr := version.CheckCompatibility(version.CurrentGaugeVersion, &r.GaugeVersionSupport)
	if compatibilityErr != nil {
		return nil, errors.New(fmt.Sprintf("Compatible runner version to %s not found. To update plugin, run `gauge --update {pluginName}`.", version.CurrentGaugeVersion))
	}
	command := getOsSpecificCommand(r)
	env := getCleanEnv(port, os.Environ())
	cmd, err := common.ExecuteCommandWithEnv(command, runnerDir, log, log, env)
	if err != nil {
		return nil, err
	}
	go func() {
		select {
		case <-killChannel:
			cmd.Process.Kill()
		}
	}()
	// Wait for the process to exit so we will get a detailed error message
	errChannel := make(chan error)
	waitAndGetErrorMessage(errChannel, cmd, log)
	return &TestRunner{Cmd: cmd, ErrorChannel: errChannel}, nil
}
示例#3
0
文件: install.go 项目: 0-T-0/gauge
func (installDesc *installDescription) getLatestCompatibleVersionTo(currentVersion *version.Version) (*versionInstallDescription, error) {
	installDesc.sortVersionInstallDescriptions()
	for _, versionInstallDesc := range installDesc.Versions {
		if err := version.CheckCompatibility(currentVersion, &versionInstallDesc.GaugeVersionSupport); err == nil {
			return &versionInstallDesc, nil
		}
	}
	return nil, fmt.Errorf("Compatible version to %s not found", currentVersion)
}
示例#4
0
func (s *MySuite) TestCheckVersionCompatibilityFailure(c *C) {
	versionsSupported := &version.VersionSupport{"0.6.5", "1.8.5"}
	gaugeVersion := &version.Version{1, 9, 9}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionsSupported), NotNil)

	versionsSupported = &version.VersionSupport{"0.0.1", "0.0.1"}
	gaugeVersion = &version.Version{0, 0, 2}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionsSupported), NotNil)

	versionsSupported = &version.VersionSupport{Minimum: "1.3.1"}
	gaugeVersion = &version.Version{1, 3, 0}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionsSupported), NotNil)

	versionsSupported = &version.VersionSupport{Minimum: "0.5.1"}
	gaugeVersion = &version.Version{0, 0, 9}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionsSupported), NotNil)

}
示例#5
0
func (s *MySuite) TestCheckVersionCompatibilitySuccess(c *C) {
	versionSupported := &version.VersionSupport{"0.6.5", "1.8.5"}
	gaugeVersion := &version.Version{0, 6, 7}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionSupported), Equals, nil)

	versionSupported = &version.VersionSupport{"0.0.1", "0.0.1"}
	gaugeVersion = &version.Version{0, 0, 1}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionSupported), Equals, nil)

	versionSupported = &version.VersionSupport{Minimum: "0.0.1"}
	gaugeVersion = &version.Version{1, 5, 2}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionSupported), Equals, nil)

	versionSupported = &version.VersionSupport{Minimum: "0.5.1"}
	gaugeVersion = &version.Version{0, 5, 1}
	c.Assert(version.CheckCompatibility(gaugeVersion, versionSupported), Equals, nil)

}
示例#6
0
// IsCompatiblePluginInstalled checks if a plugin compatible to gauge is installed
// TODO: This always checks if latest installed version of a given plugin is compatible. This should also check for older versions.
func IsCompatiblePluginInstalled(pluginName string, isRunner bool) bool {
	if isRunner {
		return isCompatibleLanguagePluginInstalled(pluginName)
	}
	pd, err := plugin.GetPluginDescriptor(pluginName, "")
	if err != nil {
		return false
	}
	return version.CheckCompatibility(version.CurrentGaugeVersion, &pd.GaugeVersionSupport) == nil
}
示例#7
0
文件: install.go 项目: 0-T-0/gauge
func IsCompatibleLanguagePluginInstalled(name string) bool {
	jsonFilePath, err := plugin.GetLanguageJSONFilePath(name)
	if err != nil {
		return false
	}

	r, err := getRunnerJSONContents(jsonFilePath)
	if err != nil {
		return false
	}
	return (version.CheckCompatibility(version.CurrentGaugeVersion, &r.GaugeVersionSupport) == nil)
}
示例#8
0
func isCompatiblePluginInstalled(pluginName string, pluginVersion string, isRunner bool) bool {
	if isRunner {
		return IsCompatibleLanguagePluginInstalled(pluginName)
	} else {
		pd, err := plugin.GetPluginDescriptor(pluginName, pluginVersion)
		if err != nil {
			return false
		}
		err = version.CheckCompatibility(version.CurrentGaugeVersion, &pd.GaugeVersionSupport)
		if err != nil {
			return false
		}
		return true
	}
}
示例#9
0
func IsCompatibleLanguagePluginInstalled(name string) bool {
	jsonFilePath, err := common.GetLanguageJSONFilePath(name)
	if err != nil {
		return false
	}
	var r runner.Runner
	contents, err := common.ReadFileContents(jsonFilePath)
	if err != nil {
		return false
	}
	err = json.Unmarshal([]byte(contents), &r)
	if err != nil {
		return false
	}
	return (version.CheckCompatibility(version.CurrentGaugeVersion, &r.GaugeVersionSupport) == nil)
}
示例#10
0
func startPluginsForExecution(manifest *manifest.Manifest) (*Handler, []string) {
	var warnings []string
	handler := &Handler{}
	envProperties := make(map[string]string)

	for _, pluginID := range manifest.Plugins {
		pd, err := GetPluginDescriptor(pluginID, "")
		if err != nil {
			warnings = append(warnings, fmt.Sprintf("Error starting plugin %s. Failed to get plugin.json. %s. To install, run `gauge --install %s`.", pluginID, err.Error(), pluginID))
			continue
		}
		compatibilityErr := version.CheckCompatibility(version.CurrentGaugeVersion, &pd.GaugeVersionSupport)
		if compatibilityErr != nil {
			warnings = append(warnings, fmt.Sprintf("Compatible %s plugin version to current Gauge version %s not found", pd.Name, version.CurrentGaugeVersion))
			continue
		}
		if isExecutionScopePlugin(pd) {
			gaugeConnectionHandler, err := conn.NewGaugeConnectionHandler(0, nil)
			if err != nil {
				warnings = append(warnings, err.Error())
				continue
			}
			envProperties[pluginConnectionPortEnv] = strconv.Itoa(gaugeConnectionHandler.ConnectionPortNumber())
			err = SetEnvForPlugin(executionScope, pd, manifest, envProperties)
			if err != nil {
				warnings = append(warnings, fmt.Sprintf("Error setting environment for plugin %s %s. %s", pd.Name, pd.Version, err.Error()))
				continue
			}

			plugin, err := StartPlugin(pd, executionScope)
			if err != nil {
				warnings = append(warnings, fmt.Sprintf("Error starting plugin %s %s. %s", pd.Name, pd.Version, err.Error()))
				continue
			}
			pluginConnection, err := gaugeConnectionHandler.AcceptConnection(config.PluginConnectionTimeout(), make(chan error))
			if err != nil {
				warnings = append(warnings, fmt.Sprintf("Error starting plugin %s %s. Failed to connect to plugin. %s", pd.Name, pd.Version, err.Error()))
				plugin.pluginCmd.Process.Kill()
				continue
			}
			plugin.connection = pluginConnection
			handler.addPlugin(pluginID, plugin)
		}

	}
	return handler, warnings
}
示例#11
0
文件: install.go 项目: 0-T-0/gauge
func installPluginWithDescription(installDescription *installDescription, currentVersion string) installResult {
	var versionInstallDescription *versionInstallDescription
	var err error
	if currentVersion != "" {
		versionInstallDescription, err = installDescription.getVersion(currentVersion)
		if err != nil {
			return installError(err.Error())
		}
		if compatibilityError := version.CheckCompatibility(version.CurrentGaugeVersion, &versionInstallDescription.GaugeVersionSupport); compatibilityError != nil {
			return installError(fmt.Sprintf("Plugin Version %s-%s is not supported for gauge %s : %s", installDescription.Name, versionInstallDescription.Version, version.CurrentGaugeVersion.String(), compatibilityError.Error()))
		}
	} else {
		versionInstallDescription, err = installDescription.getLatestCompatibleVersionTo(version.CurrentGaugeVersion)
		if err != nil {
			return installError(fmt.Sprintf("Could not find compatible version for plugin %s. : %s", installDescription.Name, err))
		}
	}
	return installPluginVersion(installDescription, versionInstallDescription)
}