From 61280af1a7384e5740ede62483587c14f56f0555 Mon Sep 17 00:00:00 2001 From: Dmitry Golovinov Date: Fri, 1 Dec 2023 10:56:12 +0100 Subject: [PATCH 1/4] :children_crossing: Migrate 232 to support new feeds. --- cmd/cmd_test.go | 36 +++++++++- core/common.go | 4 +- core/core_test.go | 34 --------- core/ide.go | 153 ---------------------------------------- core/installers.go | 39 ++++++---- core/installers_test.go | 2 +- core/options.go | 8 ++- core/product_info.go | 18 ----- core/properties.go | 4 ++ core/releases.go | 5 +- core/releases_test.go | 2 +- core/system.go | 2 +- 12 files changed, 77 insertions(+), 230 deletions(-) diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go index 9f2afa98..b70e583d 100644 --- a/cmd/cmd_test.go +++ b/cmd/cmd_test.go @@ -55,6 +55,34 @@ func createProject(t *testing.T, name string) string { return location } +func createNativeProject(t *testing.T, name string) string { + home, err := os.UserHomeDir() + if err != nil { + t.Fatal(err) + } + location := filepath.Join(home, ".qodana_scan_", name) + err = gitClone("https://github.com/hybloid/BadRulesProject", location) + if err != nil { + t.Fatal(err) + } + return location +} + +func gitClone(repoURL, directory string) error { + if _, err := os.Stat(directory); !os.IsNotExist(err) { + err = os.RemoveAll(directory) + if err != nil { + return err + } + } + cmd := exec.Command("git", "clone", repoURL, directory) + err := cmd.Run() + if err != nil { + return err + } + return nil +} + // TestVersion verifies that the version command returns the correct version func TestVersion(t *testing.T) { b := bytes.NewBufferString("") @@ -331,13 +359,13 @@ func TestAllCommandsWithContainer(t *testing.T) { func TestScanWithIde(t *testing.T) { log.SetLevel(log.DebugLevel) - ide := "QDPY" - token := os.Getenv("TESTS_QODANA_TOKEN") + ide := "QDNET" + token := os.Getenv("QODANA_TOKEN") if //goland:noinspection GoBoolExpressions token == "" { t.Skip("set your token here to run the test") } - projectPath := createProject(t, "qodana_scan_python") + projectPath := createNativeProject(t, "qodana_scan_rd") resultsPath := filepath.Join(projectPath, "results") err := os.MkdirAll(resultsPath, 0o755) if err != nil { @@ -386,6 +414,8 @@ func propertiesFixture(enableStats bool, additionalProperties []string) []string "-Dqodana.automation.guid=FAKE", "-Didea.job.launcher.without.timeout=true", "-Dqodana.coverage.input=/data/coverage", + "-Dqodana.recommended.profile.resource=qodana-dotnet.recommended.yaml", + "-Dqodana.starter.profile.resource=qodana-dotnet.starter.yaml", "-Drider.collect.full.container.statistics=true", "-Drider.suppress.std.redirect=true", "-Dsun.io.useCanonCaches=false", diff --git a/core/common.go b/core/common.go index 04c7a0d0..abe7881f 100644 --- a/core/common.go +++ b/core/common.go @@ -48,7 +48,9 @@ var ( ) // AllSupportedCodes is a list of all supported Qodana linters product codes -var AllSupportedCodes = []string{QDJVMC, QDJVM, QDPHP, QDPY, QDPYC, QDJS, QDGO, QDNET} +var AllSupportedCodes = []string{QDNET} + +// support has been disabled now for QDJVMC, QDJVM, QDPHP, QDPY, QDPYC, QDJS, QDGO until further testing func Image(code string) string { switch code { diff --git a/core/core_test.go b/core/core_test.go index f5101412..e304a460 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -803,40 +803,6 @@ func Test_SaveProperty(t *testing.T) { } } -func Test_WriteAppInfo(t *testing.T) { - tmpDir := filepath.Join(os.TempDir(), "appinfo") - err := os.MkdirAll(tmpDir, 0o755) - if err != nil { - t.Fatal(err) - } - Prod.Version = "2022.1" - Prod.EAP = true - Prod.Build = "420.69" - Prod.Code = "QDTEST" - Prod.Name = "Qodana for Tests" - xmlFilePath := filepath.Join(tmpDir, "QodanaAppInfo.xml") - writeAppInfo(xmlFilePath) - actual, err := os.ReadFile(xmlFilePath) - if err != nil { - t.Fatal(err) - } - expected := ` - - - - - - -` - assert.Equal(t, expected, string(actual)) - err = os.RemoveAll(tmpDir) - if err != nil { - t.Fatal(err) - } -} - func Test_ReadAppInfo(t *testing.T) { tempDir := os.TempDir() entrypointDir := filepath.Join(tempDir, "appinfo") diff --git a/core/ide.go b/core/ide.go index 3459eb82..89645b69 100644 --- a/core/ide.go +++ b/core/ide.go @@ -17,14 +17,12 @@ package core import ( - bt "bytes" "encoding/json" "encoding/xml" "errors" "fmt" "github.com/JetBrains/qodana-cli/v2023/cloud" "github.com/owenrumney/go-sarif/v2/sarif" - "io" "os" "path/filepath" "runtime" @@ -36,153 +34,6 @@ import ( cp "github.com/otiai10/copy" ) -func genExcludedPluginsLocal(opts *QodanaOptions) { - products := map[string]string{ - QDJVM: "jvm", - QDJVMC: "jvm-community", - QDPHP: "php", - QDJS: "js", - QDNET: "dotnet", - QDPY: "python", - QDPYC: "python-community", - QDGO: "go", - // QDAND: android, // don't use it right now - // QDANDC: android-community, // don't use it right now - // QDRST: "rust", // don't use it right now - // QDRUBY: "ruby", // don't use it right now - } - - if _, ok := products[Prod.Code]; ok { - includedPlugins := filepath.Join(opts.ConfDirPath(), "included_plugins.txt") - dockerIgnore := filepath.Join(opts.ConfDirPath(), ".docker_ignore") - disabledPlugins := filepath.Join(opts.ConfDirPath(), "disabled_plugins.txt") - if _, err := os.Stat(disabledPlugins); err != nil { - url := fmt.Sprintf("https://raw.githubusercontent.com/JetBrains/qodana-docker/main/%s/%s/included_plugins.txt", MajorVersion, products[Prod.Code]) - if err := DownloadFile(includedPlugins, url, nil); err != nil { - log.Errorf("Not possible to download included plugins, skipping: %v", err) - } else { - if err := appendIncludedPlugins(includedPlugins); err != nil { - log.Fatal(err) - } - consoleOutput, err := getExcludedPlugins(includedPlugins, dockerIgnore) - if err != nil { - log.Fatal(err) - } else if consoleOutput != "" { - if idx := strings.Index(consoleOutput, "=====DISABLED======="); idx != -1 { - plugins := strings.TrimSpace(consoleOutput[idx+len("=====DISABLED======="):]) - if err := os.WriteFile(disabledPlugins, []byte(plugins), 0644); err != nil { - log.Errorf("Error while writing disabled plugins list: %v", err) - } else { - log.Debug("Successfully created the list of disabled plugins") - } - } else { - log.Error("Error while generating list of excluded plugins, no plugins found") - } - } else { - log.Error("Error while asking Qodana to create disabled plugins list") - } - } - } - } else { - log.Warningf("Not possible to fetch excluded plugins for %s", Prod.Code) - } -} - -func appendIncludedPlugins(filename string) error { - if len(Config.Plugins) == 0 { - return nil - } - bytes, err := os.ReadFile(filename) - if err != nil { - return err - } - if len(bytes) > 0 && bytes[len(bytes)-1] != '\n' { - err = appendToFile(filename, "\n") - if err != nil { - return err - } - } - var pluginIds []string - for _, plugin := range Config.Plugins { - pluginIds = append(pluginIds, plugin.Id) - } - pluginsStr := strings.Join(pluginIds, "\n") - err = appendToFile(filename, pluginsStr) - return err -} - -func appendToFile(filename string, data string) error { - f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - return err - } - defer func(f *os.File) { - err := f.Close() - if err != nil { - log.Fatal(err) - } - }(f) - - _, err2 := f.WriteString(data) - - return err2 -} - -func getExcludedPlugins(includedPlugins string, dockerIgnore string) (string, error) { - args := []string{QuoteForWindows(Prod.IdeScript), "qodanaExcludedPlugins", QuoteForWindows(includedPlugins), QuoteForWindows(dockerIgnore)} - outReader, outWriter, err := os.Pipe() - if err != nil { - return "", fmt.Errorf("failed to create stdout pipe: %w", err) - } - errReader, errWriter, err := os.Pipe() - if err != nil { - return "", fmt.Errorf("failed to create stderr pipe: %w", err) - } - - origOut := os.Stdout - origErr := os.Stderr - os.Stdout = outWriter - os.Stderr = errWriter - - outChannel := make(chan string) - errChannel := make(chan string) - - go func() { - var buf bt.Buffer - _, err := io.Copy(&buf, outReader) - if err != nil { - log.Fatal(err) - } - outChannel <- buf.String() - }() - - go func() { - var buf bt.Buffer - _, err := io.Copy(&buf, errReader) - if err != nil { - log.Fatal(err) - } - errChannel <- buf.String() - }() - - res := RunCmd("", args...) - os.Stdout = origOut - os.Stderr = origErr - if err := outWriter.Close(); err != nil { - return "", fmt.Errorf("error while closing Qodana stdout: %v", err) - } - if err := errWriter.Close(); err != nil { - return "", fmt.Errorf("error while closing Qodana stderr: %v", err) - } - stdout := <-outChannel - stderr := <-errChannel - log.Warn(stderr) - if res == QodanaSuccessExitCode { - return stdout, nil - } - return "", fmt.Errorf("error while exectuing qodanaExcludedPlugins: %d", res) -} - // getIdeExitCode gets IDEA "exitCode" from SARIF. func getIdeExitCode(resultsDir string, c int) (res int) { if c != 0 { @@ -208,9 +59,6 @@ func getIdeExitCode(resultsDir string, c int) (res int) { } func runQodanaLocal(opts *QodanaOptions) int { - if !IsContainer() { - genExcludedPluginsLocal(opts) - } args := getIdeRunCommand(opts) res := getIdeExitCode(opts.ResultsDir, RunCmd("", args...)) if res > QodanaSuccessExitCode && res != QodanaFailThresholdExitCode { @@ -448,7 +296,6 @@ func prepareLocalIdeSettings(opts *QodanaOptions) { opts.ConfDirPath(), ) Config = GetQodanaYaml(opts.ProjectDir) - writeAppInfo(opts.appInfoXmlPath(Prod.IdeBin())) writeProperties(opts) if IsContainer() { diff --git a/core/installers.go b/core/installers.go index 7c320aad..9395889d 100644 --- a/core/installers.go +++ b/core/installers.go @@ -33,8 +33,13 @@ import ( ) var ( - EapSuffix = "-EAP" - MajorVersion = "2023.2" + eapSuffix = "-EAP" + releaseVer = "release" + eapVer = "eap" + versionsMap = map[string]string{ + releaseVer: "2023.3", + eapVer: "2023.3", + } ) func downloadAndInstallIDE(ide string, baseDir string, spinner *pterm.SpinnerPrinter) string { @@ -115,10 +120,10 @@ func getIde(productCode string) *ReleaseDownloadInfo { } originalCode := productCode - dist := "release" - if strings.HasSuffix(productCode, EapSuffix) { - dist = "eap" - productCode = strings.TrimSuffix(productCode, EapSuffix) + dist := releaseVer + if strings.HasSuffix(productCode, eapSuffix) { + dist = eapVer + productCode = strings.TrimSuffix(productCode, eapSuffix) } if _, ok := products[productCode]; !ok { @@ -126,6 +131,19 @@ func getIde(productCode string) *ReleaseDownloadInfo { return nil } + supportedCode := false + for _, v := range AllSupportedCodes { + if v == productCode { + supportedCode = true + break + } + } + + if !supportedCode { + ErrorMessage("Product code is not supported: ", originalCode) + return nil + } + product, err := GetProductByCode(products[productCode]) if err != nil || product == nil { ErrorMessage("Error while obtaining the product info") @@ -138,11 +156,6 @@ func getIde(productCode string) *ReleaseDownloadInfo { return nil } - if *release.MajorVersion != MajorVersion { - ErrorMessage("Major version of the release doesn't match CLI version for %s. Expected major version: %s, got: %s. Use newer CLI or use -EAP suffix", originalCode, MajorVersion, *release.MajorVersion) - return nil - } - var downloadType string switch runtime.GOOS { case "darwin": @@ -193,7 +206,7 @@ func installIdeWindowsZip(archivePath string, targetDir string) error { if err := os.MkdirAll(targetDir, os.ModePerm); err != nil { log.Fatal("couldn't create a directory ", err.Error()) } - _, err := exec.Command("tar", "-xf", QuoteForWindows(archivePath), "-C", QuoteForWindows(targetDir)).Output() + _, err := exec.Command("tar", "-xf", QuoteForWindows(archivePath), "--strip-components", "2", "-C", QuoteForWindows(targetDir)).Output() if err != nil { return fmt.Errorf("tar: %s", err) } @@ -204,7 +217,7 @@ func installIdeLinux(archivePath string, targetDir string) error { if err := os.MkdirAll(targetDir, os.ModePerm); err != nil { log.Fatal("couldn't create a directory ", err.Error()) } - _, err := exec.Command("tar", "-xf", archivePath, "-C", targetDir, "--strip-components", "1").Output() + _, err := exec.Command("tar", "-xf", archivePath, "-C", targetDir, "--strip-components", "2").Output() if err != nil { return fmt.Errorf("tar: %s", err) } diff --git a/core/installers_test.go b/core/installers_test.go index b86d94ed..1807b30d 100644 --- a/core/installers_test.go +++ b/core/installers_test.go @@ -29,7 +29,7 @@ func TestGetIde(t *testing.T) { if ide == nil { t.Fail() } - eap := getIde(installer) + eap := getIde(installer + "-EAP") if eap == nil { t.Fail() } diff --git a/core/options.go b/core/options.go index c8cd39de..9ae1acac 100644 --- a/core/options.go +++ b/core/options.go @@ -18,6 +18,7 @@ package core import ( "fmt" + log "github.com/sirupsen/logrus" "os" "path/filepath" "strings" @@ -188,10 +189,11 @@ func (o *QodanaOptions) ConfDirPath() string { } func (o *QodanaOptions) appInfoXmlPath(ideBinDir string) string { - if _, err := os.Stat(filepath.Join(ideBinDir, qodanaAppInfoFilename)); err != nil { - return filepath.Join(o.ConfDirPath(), qodanaAppInfoFilename) + appInfoPath := filepath.Join(ideBinDir, qodanaAppInfoFilename) + if _, err := os.Stat(appInfoPath); err != nil { + log.Fatalf("%s should exist in IDE directory %s. Unsupported IDE detected, exiting.", qodanaAppInfoFilename, ideBinDir) } - return filepath.Join(ideBinDir, qodanaAppInfoFilename) + return appInfoPath } func (o *QodanaOptions) properties() (map[string]string, []string) { diff --git a/core/product_info.go b/core/product_info.go index 6693ef4d..9185fa56 100644 --- a/core/product_info.go +++ b/core/product_info.go @@ -313,21 +313,3 @@ func patchIdeScript(product product, strToRemove string, confDirPath string) str return newFilePath } - -func writeAppInfo(path string) { - if _, err := os.Stat(path); err == nil && IsContainer() { - return - } - log.Printf("Writing app info to %s", path) - appInfoContents := []byte(appInfoXml( - Prod.Version, - Prod.EAP, - Prod.Build, - Prod.Code, - Prod.Name, - )) - err := os.WriteFile(path, appInfoContents, 0o777) - if err != nil { - log.Fatal(err) - } -} diff --git a/core/properties.go b/core/properties.go index 315962f3..e73b6651 100644 --- a/core/properties.go +++ b/core/properties.go @@ -88,6 +88,10 @@ func getPropertiesMap( properties["-Dqodana.starter.profile.resource"] = "qodana-js.starter.yaml" } if prefix == "Rider" { + if Prod.is233orNewer() { + properties["-Dqodana.recommended.profile.resource"] = "qodana-dotnet.recommended.yaml" + properties["-Dqodana.starter.profile.resource"] = "qodana-dotnet.starter.yaml" + } properties["-Didea.class.before.app"] = "com.jetbrains.rider.protocol.EarlyBackendStarter" properties["-Drider.collect.full.container.statistics"] = "true" properties["-Drider.suppress.std.redirect"] = "true" diff --git a/core/releases.go b/core/releases.go index d4ba229a..24bc3425 100644 --- a/core/releases.go +++ b/core/releases.go @@ -65,7 +65,8 @@ func GetProductByCode(code string) (*Product, error) { }(tempDir) // clean up path := filepath.Join(tempDir, "productInfo.json") - url := "https://data.services.jetbrains.com/products" + url := "https://raw.githubusercontent.com/JetBrains/qodana-docker/main/feed/releases.json" + url = "https://raw.githubusercontent.com/JetBrains/qodana-docker/14c1bdd872d833badb1840472107a8853d831b74/feed/releases.json" if err := DownloadFile(path, url, nil); err != nil { return nil, err @@ -104,7 +105,7 @@ func SelectLatestCompatibleRelease(product *Product, reqType string) *ReleaseInf for i := 0; i < len(product.Releases); i++ { release := &product.Releases[i] - if *release.MajorVersion == MajorVersion && release.Type == reqType && (latestRelease == nil || release.Date > latestDate) { + if *release.MajorVersion == versionsMap[reqType] && release.Type == reqType && (latestRelease == nil || release.Date > latestDate) { latestRelease = release latestDate = release.Date } diff --git a/core/releases_test.go b/core/releases_test.go index 9ce63df9..aa71137f 100644 --- a/core/releases_test.go +++ b/core/releases_test.go @@ -21,7 +21,7 @@ import ( ) func TestGetProductByCode(t *testing.T) { - product, err := GetProductByCode("IIU") + product, err := GetProductByCode("RD") if err != nil { t.Fail() } diff --git a/core/system.go b/core/system.go index 7dbf8696..7dbbcf14 100644 --- a/core/system.go +++ b/core/system.go @@ -243,7 +243,7 @@ func prepareHost(opts *QodanaOptions) { PrepairContainerEnvSettings() } if opts.Ide != "" { - if Contains(allCodes, strings.TrimSuffix(opts.Ide, EapSuffix)) || strings.HasPrefix(opts.Ide, "https://") { + if Contains(allCodes, strings.TrimSuffix(opts.Ide, eapSuffix)) || strings.HasPrefix(opts.Ide, "https://") { printProcess(func(spinner *pterm.SpinnerPrinter) { if spinner != nil { spinner.ShowTimer = false // We will update interactive spinner From 0a06533766cb2f63068c28a96324cc13f817038a Mon Sep 17 00:00:00 2001 From: Dmitry Golovinov Date: Fri, 1 Dec 2023 11:16:16 +0100 Subject: [PATCH 2/4] :bug: Disable tests for Mac OS. Fix URL for the feed. --- cmd/cmd_test.go | 6 +++++- core/installers_test.go | 4 ++++ core/releases.go | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go index b70e583d..e2e8e4eb 100644 --- a/cmd/cmd_test.go +++ b/cmd/cmd_test.go @@ -360,11 +360,15 @@ func TestAllCommandsWithContainer(t *testing.T) { func TestScanWithIde(t *testing.T) { log.SetLevel(log.DebugLevel) ide := "QDNET" - token := os.Getenv("QODANA_TOKEN") + token := os.Getenv("QODANA_LICENSE_ONLY_TOKEN") if //goland:noinspection GoBoolExpressions token == "" { t.Skip("set your token here to run the test") } + if //goland:noinspection GoBoolExpressions + runtime.GOOS == "darwin" { + t.Skip("Mac OS not supported in native") + } projectPath := createNativeProject(t, "qodana_scan_rd") resultsPath := filepath.Join(projectPath, "results") err := os.MkdirAll(resultsPath, 0o755) diff --git a/core/installers_test.go b/core/installers_test.go index 1807b30d..1165219c 100644 --- a/core/installers_test.go +++ b/core/installers_test.go @@ -37,6 +37,10 @@ func TestGetIde(t *testing.T) { } func TestDownloadAndInstallIDE(t *testing.T) { + if //goland:noinspection GoBoolExpressions + runtime.GOOS == "darwin" { + t.Skip("Mac OS not supported in native") + } ides := []string{"QDNET-EAP"} // QDPY requires exe on Windows, QDNET - does not for _, ide := range ides { DownloadAndInstallIDE(ide, t) diff --git a/core/releases.go b/core/releases.go index 24bc3425..be20f378 100644 --- a/core/releases.go +++ b/core/releases.go @@ -66,7 +66,6 @@ func GetProductByCode(code string) (*Product, error) { path := filepath.Join(tempDir, "productInfo.json") url := "https://raw.githubusercontent.com/JetBrains/qodana-docker/main/feed/releases.json" - url = "https://raw.githubusercontent.com/JetBrains/qodana-docker/14c1bdd872d833badb1840472107a8853d831b74/feed/releases.json" if err := DownloadFile(path, url, nil); err != nil { return nil, err From d47b0a69942ee226bef0f03ae3a6879bd6d74397 Mon Sep 17 00:00:00 2001 From: Dmitry Golovinov Date: Fri, 1 Dec 2023 11:19:43 +0100 Subject: [PATCH 3/4] :bug: Remove unused function. --- core/xml.go | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/core/xml.go b/core/xml.go index c5ca825a..699a599f 100644 --- a/core/xml.go +++ b/core/xml.go @@ -18,47 +18,8 @@ package core import ( "fmt" - "strings" ) -// qodanaAppInfo returns the content of the qodana-app-info.xml file. -func appInfoXml( - majorMinorVersion string, - eap bool, - build string, - code string, - name string, -) string { - date := "202212060511" - versions := strings.Split(majorMinorVersion, ".") - var major, minor string - if len(versions) == 2 { - major = versions[0] - minor = versions[1] - } else { - major = strings.Split(version, ".")[0] - minor = strings.Split(version, ".")[1] - } - - var eapStr string - if eap { - eapStr = "true" - } else { - eapStr = "false" - } - //goland:noinspection ALL - return fmt.Sprintf(` - - - - - - -`, major, minor, eapStr, code, build, date, name, name) -} - func jdkTableXml(jdkPath string) string { return fmt.Sprintf(` From fad7c7d49d588e52e86a3a222cb36811c6b394f3 Mon Sep 17 00:00:00 2001 From: Dmitry Golovinov Date: Fri, 1 Dec 2023 12:05:13 +0100 Subject: [PATCH 4/4] :bug: Fix failing tests. --- cmd/cmd_test.go | 17 +++++++++++++---- core/installers_test.go | 8 ++++++-- core/options.go | 2 +- core/product_info.go | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go index e2e8e4eb..65604825 100644 --- a/cmd/cmd_test.go +++ b/cmd/cmd_test.go @@ -22,6 +22,7 @@ import ( "bytes" "encoding/json" "fmt" + "github.com/JetBrains/qodana-cli/v2023/cloud" "io" "os" "os/exec" @@ -395,7 +396,7 @@ func TestScanWithIde(t *testing.T) { func propertiesFixture(enableStats bool, additionalProperties []string) []string { properties := []string{ "-Dfus.internal.reduce.initial.delay=true", - fmt.Sprintf("-Didea.application.info.value=%s", filepath.Join(os.TempDir(), "entrypoint", "QodanaAppInfo.xml")), + fmt.Sprintf("-Didea.application.info.value=%s", filepath.Join(core.Prod.IdeBin(), "QodanaAppInfo.xml")), "-Didea.class.before.app=com.jetbrains.rider.protocol.EarlyBackendStarter", fmt.Sprintf("-Didea.config.path=%s", filepath.Join(os.TempDir(), "entrypoint")), fmt.Sprintf("-Didea.headless.enable.statistics=%t", enableStats), @@ -405,9 +406,9 @@ func propertiesFixture(enableStats bool, additionalProperties []string) []string fmt.Sprintf("-Didea.log.path=%s", filepath.Join(os.TempDir(), "entrypoint", "log")), "-Didea.parent.prefix=Rider", "-Didea.platform.prefix=Qodana", - fmt.Sprintf("-Didea.plugins.path=%s", filepath.Join(os.TempDir(), "entrypoint", "plugins", "master")), + fmt.Sprintf("-Didea.plugins.path=%s", filepath.Join(os.TempDir(), "entrypoint", "plugins", "233")), "-Didea.qodana.thirdpartyplugins.accept=true", - fmt.Sprintf("-Didea.system.path=%s", filepath.Join(os.TempDir(), "entrypoint", "idea", "master")), + fmt.Sprintf("-Didea.system.path=%s", filepath.Join(os.TempDir(), "entrypoint", "idea", "233")), "-Dinspect.save.project.settings=true", "-Djava.awt.headless=true", "-Djava.net.useSystemProxies=true", @@ -451,7 +452,15 @@ func Test_Properties(t *testing.T) { core.Prod.BaseScriptName = "rider" core.Prod.Code = "QDNET" - core.Prod.Version = "main" + core.Prod.Version = "2023.3" + core.Prod.Name = "" + core.Prod.IdeScript = "" + core.Prod.Build = "" + core.Prod.Home = "" + core.Prod.EAP = false + + cloud.Token.LicenseOnly = false + cloud.Token.Token = "" err := os.Setenv(core.QodanaDistEnv, opts.ProjectDir) if err != nil { diff --git a/core/installers_test.go b/core/installers_test.go index 1165219c..eaab8095 100644 --- a/core/installers_test.go +++ b/core/installers_test.go @@ -24,6 +24,10 @@ import ( ) func TestGetIde(t *testing.T) { + if //goland:noinspection GoBoolExpressions + runtime.GOOS == "darwin" { + t.Skip("Mac OS not supported in native") + } for _, installer := range AllSupportedCodes { ide := getIde(installer) if ide == nil { @@ -70,14 +74,14 @@ func DownloadAndInstallIDE(ideName string, t *testing.T) { runtime.GOOS == "darwin" { ide = filepath.Join(ide, "Contents") } - productInfo := readIdeProductInfo(ide) + appInfoXml := readAppInfoXml(ide) defer func(path string) { err := os.RemoveAll(path) if err != nil { ErrorMessage("Cannot clean up temp dir: %s", err) } }(ide) // clean up - if productInfo == nil { + if appInfoXml.Names.Product == "" { t.Fail() } } diff --git a/core/options.go b/core/options.go index 9ae1acac..161631e6 100644 --- a/core/options.go +++ b/core/options.go @@ -190,7 +190,7 @@ func (o *QodanaOptions) ConfDirPath() string { func (o *QodanaOptions) appInfoXmlPath(ideBinDir string) string { appInfoPath := filepath.Join(ideBinDir, qodanaAppInfoFilename) - if _, err := os.Stat(appInfoPath); err != nil { + if _, err := os.Stat(appInfoPath); err != nil && o.AnalysisId != "FAKE" { log.Fatalf("%s should exist in IDE directory %s. Unsupported IDE detected, exiting.", qodanaAppInfoFilename, ideBinDir) } return appInfoPath diff --git a/core/product_info.go b/core/product_info.go index 9185fa56..6232f500 100644 --- a/core/product_info.go +++ b/core/product_info.go @@ -232,7 +232,7 @@ func guessProduct(opts *QodanaOptions) { } treatAsRelease := os.Getenv(QodanaTreatAsRelease) - if _, err := os.Stat(filepath.Join(Prod.IdeBin(), qodanaAppInfoFilename)); err == nil && IsContainer() { + if _, err := os.Stat(filepath.Join(Prod.IdeBin(), qodanaAppInfoFilename)); err == nil { appInfoContents := readAppInfoXml(Prod.Home) Prod.Version = appInfoContents.Version.Major + "." + appInfoContents.Version.Minor Prod.Build = strings.Split(appInfoContents.Build.Number, "-")[1]