Skip to content

Commit

Permalink
🐛 Fix failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hybloid committed Dec 1, 2023
1 parent d47b0a6 commit fad7c7d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
17 changes: 13 additions & 4 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/JetBrains/qodana-cli/v2023/cloud"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -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),
Expand All @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions core/installers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}
2 changes: 1 addition & 1 deletion core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/product_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit fad7c7d

Please sign in to comment.