本文整理匯總了Golang中github.com/getgauge/gauge/version.CheckCompatibility函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckCompatibility函數的具體用法?Golang CheckCompatibility怎麽用?Golang CheckCompatibility使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CheckCompatibility函數的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: startRunner
// 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: startRunner
// 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: getLatestCompatibleVersionTo
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: TestCheckVersionCompatibilityFailure
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: TestCheckVersionCompatibilitySuccess
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: IsCompatiblePluginInstalled
// 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: IsCompatibleLanguagePluginInstalled
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: isCompatiblePluginInstalled
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: IsCompatibleLanguagePluginInstalled
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: startPluginsForExecution
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: installPluginWithDescription
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)
}