From 327dc4b76c86bbb12de8a0867151a7f0308db032 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 9 Nov 2023 13:51:25 +0300 Subject: [PATCH 1/5] try to publish for pycharm --- utbot-intellij-python/build.gradle.kts | 10 +- .../python/ui/actions/GenerateTestsAction.kt | 25 + .../src/main/resources/META-INF/plugin.xml | 56 ++ .../main/resources/META-INF/pluginIcon.svg | 4 + .../main/resources/META-INF/withPython.xml | 4 + .../src/main/resources/application.properties | 5 + .../src/main/resources/log4j2.xml | 34 + .../src/main/resources/settings.properties | 607 ++++++++++++++++++ 8 files changed, 740 insertions(+), 5 deletions(-) create mode 100644 utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/ui/actions/GenerateTestsAction.kt create mode 100644 utbot-intellij-python/src/main/resources/META-INF/plugin.xml create mode 100644 utbot-intellij-python/src/main/resources/META-INF/pluginIcon.svg create mode 100644 utbot-intellij-python/src/main/resources/META-INF/withPython.xml create mode 100644 utbot-intellij-python/src/main/resources/application.properties create mode 100644 utbot-intellij-python/src/main/resources/log4j2.xml create mode 100644 utbot-intellij-python/src/main/resources/settings.properties diff --git a/utbot-intellij-python/build.gradle.kts b/utbot-intellij-python/build.gradle.kts index cf1e5ea9f1..531d6e75c2 100644 --- a/utbot-intellij-python/build.gradle.kts +++ b/utbot-intellij-python/build.gradle.kts @@ -1,7 +1,5 @@ -val intellijPluginVersion: String? by rootProject +val semVer: String? by rootProject val kotlinLoggingVersion: String? by rootProject -val apacheCommonsTextVersion: String? by rootProject -val jacksonVersion: String? by rootProject // === IDE settings === val projectType: String by rootProject @@ -54,8 +52,10 @@ tasks { targetCompatibility = JavaVersion.VERSION_17 } - test { - useJUnitPlatform() + patchPluginXml { + sinceBuild.set("223") + untilBuild.set("232.*") + version.set(semVer) } } diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/ui/actions/GenerateTestsAction.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/ui/actions/GenerateTestsAction.kt new file mode 100644 index 0000000000..ccbacbd9a5 --- /dev/null +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/ui/actions/GenerateTestsAction.kt @@ -0,0 +1,25 @@ +package org.utbot.intellij.plugin.python.ui.actions + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.components.service +import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant +import org.utbot.intellij.plugin.settings.Settings + +class GenerateTestsAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + LanguageAssistant.get(e)?.actionPerformed(e) + } + + override fun update(e: AnActionEvent) { + val languageAssistant = LanguageAssistant.get(e) + if (languageAssistant == null) { + e.presentation.isEnabled = false + } else { + languageAssistant.update(e) + } + } + + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT +} diff --git a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml new file mode 100644 index 0000000000..39ed71a602 --- /dev/null +++ b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,56 @@ + + + + org.utbot.pycharm + UnitTestBot Pycharm + utbot.org + com.intellij.modules.platform + + com.intellij.modules.python + + + + + + + + + + + + + + + + + +
+ Discover UnitTestBot key features in our latest release: +
    +
  • generating ready-to-use test cases — with valid inputs, method bodies, assertions, and comments
  • +
  • maximizing branch coverage in regression suite while keeping the number of tests minimized
  • +
  • finding deeply hidden code defects and expressing them as tests
  • +
  • smart fuzzing platform
  • +
+ Try UnitTestBot online demo to see how it generates tests for your code in real time. +
+ Contribute to UnitTestBot via GitHub. +
+ Found a bug? File an issue. +
+ Have an idea? Start a discussion. + ]]> +
+ + + +
diff --git a/utbot-intellij-python/src/main/resources/META-INF/pluginIcon.svg b/utbot-intellij-python/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000000..d24574d6dd --- /dev/null +++ b/utbot-intellij-python/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/utbot-intellij-python/src/main/resources/META-INF/withPython.xml b/utbot-intellij-python/src/main/resources/META-INF/withPython.xml new file mode 100644 index 0000000000..f272fd7601 --- /dev/null +++ b/utbot-intellij-python/src/main/resources/META-INF/withPython.xml @@ -0,0 +1,4 @@ + + + com.intellij.modules.python + \ No newline at end of file diff --git a/utbot-intellij-python/src/main/resources/application.properties b/utbot-intellij-python/src/main/resources/application.properties new file mode 100644 index 0000000000..f5af5a168d --- /dev/null +++ b/utbot-intellij-python/src/main/resources/application.properties @@ -0,0 +1,5 @@ +# suppress inspection "HttpUrlsUsage" for whole file +backing.service.possibleEndpoints=http://utbot.org +backing.service.urlPath=/utbot/errors +backing.service.port=11000 +request.timeoutMillis=5000 \ No newline at end of file diff --git a/utbot-intellij-python/src/main/resources/log4j2.xml b/utbot-intellij-python/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..6a9ae540c8 --- /dev/null +++ b/utbot-intellij-python/src/main/resources/log4j2.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utbot-intellij-python/src/main/resources/settings.properties b/utbot-intellij-python/src/main/resources/settings.properties new file mode 100644 index 0000000000..657e42f4f4 --- /dev/null +++ b/utbot-intellij-python/src/main/resources/settings.properties @@ -0,0 +1,607 @@ +# Copyright (c) 2023 utbot.org +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Setting to disable coroutines debug explicitly. +# Set it to false if debug info is required. +# +# Default value is [true] +#disableCoroutinesDebug=true + +# +# Make `true` for interactive mode (like Intellij plugin). If `false` UTBot can apply certain optimizations. +# +# Default value is [true] +#classfilesCanChange=true + +# +# Timeout for Z3 solver.check calls. +# Set it to 0 to disable timeout. +# +# Default value is [1000] +#checkSolverTimeoutMillis=1000 + +# +# Timeout for symbolic execution +# +# Default value is [60000] +#utBotGenerationTimeoutInMillis=60000 + +# +# Random seed in path selector. +# Set null to disable random. +# +# Default value is [42] +#seedInPathSelector=42 + +# +# Type of path selector. +# +# COVERED_NEW_SELECTOR: [CoveredNewSelector] +# INHERITORS_SELECTOR: [InheritorsSelector] +# BFS_SELECTOR: [BFSSelector] +# SUBPATH_GUIDED_SELECTOR: [SubpathGuidedSelector] +# CPI_SELECTOR: [CPInstSelector] +# FORK_DEPTH_SELECTOR: [ForkDepthSelector] +# ML_SELECTOR: [MLSelector] +# TORCH_SELECTOR: [TorchSelector] +# RANDOM_SELECTOR: [RandomSelector] +# RANDOM_PATH_SELECTOR: [RandomPathSelector] +# +# Default value is [INHERITORS_SELECTOR] +#pathSelectorType=INHERITORS_SELECTOR + +# +# Type of MLSelector recalculation. +# +# WITH_RECALCULATION: [MLSelectorWithRecalculation] +# WITHOUT_RECALCULATION: [MLSelectorWithoutRecalculation] +# +# Default value is [WITHOUT_RECALCULATION] +#mlSelectorRecalculationType=WITHOUT_RECALCULATION + +# +# Type of [MLPredictor]. +# +# MLP: [MultilayerPerceptronPredictor] +# LINREG: [LinearRegressionPredictor] +# +# Default value is [MLP] +#mlPredictorType=MLP + +# +# Steps limit for path selector. +# +# Default value is [3500] +#pathSelectorStepsLimit=3500 + +# +# Determines whether path selector should save remaining states for concrete execution after stopping by strategy. +# False for all framework tests by default. +#saveRemainingStatesForConcreteExecution=true + +# +# Use debug visualization. +# Set it to true if debug visualization is needed. +# +# Default value is [false] +#useDebugVisualization=false + +# +# Set the value to true to show library classes' graphs in visualization. +# +# Default value is [false] +#showLibraryClassesInVisualization=false + +# +# Use simplification of UtExpressions. +# Set it to false to disable expression simplification. +# +# Default value is [true] +#useExpressionSimplification=true + +# +# Enable the Summarization module to generate summaries for methods under test. +# Note: if it is [SummariesGenerationType.NONE], +# all the execution for a particular method will be stored at the same nameless region. +# +# FULL: All possible analysis actions are taken +# LIGHT: Analysis actions based on sources are NOT taken +# NONE: No summaries are generated +# +# Default value is [FULL] +#summaryGenerationType=FULL + +# +# If True test comments will be generated. +# +# Default value is [true] +#enableJavaDocGeneration=true + +# +# If True cluster comments will be generated. +# +# Default value is [true] +#enableClusterCommentsGeneration=true + +# +# If True names for tests will be generated. +# +# Default value is [true] +#enableTestNamesGeneration=true + +# +# If True display names for tests will be generated. +# +# Default value is [true] +#enableDisplayNameGeneration=true + +# +# If True display name in from -> to style will be generated. +# +# Default value is [true] +#useDisplayNameArrowStyle=true + +# +# Generate summaries using plugin's custom JavaDoc tags. +# +# Default value is [true] +#useCustomJavaDocTags=true + +# +# This option regulates which [NullPointerException] check should be performed for nested methods. +# Set an option in true if you want to perform NPE check in the corresponding situations, otherwise set false. +# +# Default value is [true] +#checkNpeInNestedMethods=true + +# +# This option regulates which [NullPointerException] check should be performed for nested not private methods. +# Set an option in true if you want to perform NPE check in the corresponding situations, otherwise set false. +# +# Default value is [false] +#checkNpeInNestedNotPrivateMethods=false + +# +# This option determines whether we should generate [NullPointerException] checks for final or non-public fields +# in non-application classes. Set by true, this option highly decreases test's readability in some cases +# because of using reflection API for setting final/non-public fields in non-application classes. +# NOTE: With false value loses some executions with NPE in system classes, but often most of these executions +# are not expected by user. +# +# Default value is [false] +#maximizeCoverageUsingReflection=false + +# +# Activate or deactivate substituting static fields values set in static initializer +# with symbolic variable to try to set them another value than in initializer. +# +# Default value is [true] +#substituteStaticsWithSymbolicVariable=true + +# +# Use concrete execution. +# +# Default value is [true] +#useConcreteExecution=true + +# +# Enable code generation tests with every possible configuration +# for every method in samples. +# Important: is enabled generation requires enormous amount of time. +# +# Default value is [false] +#checkAllCombinationsForEveryTestInSamples=false + +# +# Enable transformation UtCompositeModels into UtAssembleModels using AssembleModelGenerator. +# Note: false doesn't mean that there will be no assemble models, it means that the generator will be turned off. +# Assemble models will present for lists, sets, etc. +# +# Default value is [true] +#useAssembleModelGenerator=true + +# +# Test related files from the temp directory that are older than [daysLimitForTempFiles] +# will be removed at the beginning of the test run. +# +# Default value is [3] +#daysLimitForTempFiles=3 + +# +# Enables soft constraints in the engine. +# +# Default value is [true] +#preferredCexOption=true + +# +# Type of test minimization strategy. +# +# DO_NOT_MINIMIZE_STRATEGY: Always adds new test +# COVERAGE_STRATEGY: Adds new test only if it increases coverage +# +# Default value is [COVERAGE_STRATEGY] +#testMinimizationStrategyType=COVERAGE_STRATEGY + +# +# Set to true to start fuzzing if symbolic execution haven't return anything +# +# Default value is [true] +#useFuzzing=true + +# +# Set the total attempts to improve coverage by fuzzer. +# +# Default value is [2147483647] +#fuzzingMaxAttempts=2147483647 + +# +# Fuzzer tries to generate and run tests during this time. +# +# Default value is [3000] +#fuzzingTimeoutInMillis=3000 + +# +# Find implementations of interfaces and abstract classes to fuzz. +# +# Default value is [true] +#fuzzingImplementationOfAbstractClasses=true + +# +# Use methods to mutate fields of classes different from class under test or not. +# +# Default value is [false] +#tryMutateOtherClassesFieldsWithMethods=false + +# +# Generate tests that treat possible overflows in arithmetic operations as errors +# that throw Arithmetic Exception. +# +# Default value is [false] +#treatOverflowAsError=false + +# +# Generate tests that treat assertions as error suits. +# +# Default value is [true] +#treatAssertAsErrorSuite=true + +# +# Instrument all classes before start +# +# Default value is [false] +#warmupConcreteExecution=false + +# +# Ignore string literals during the code analysis to make possible to analyze antlr. +# It is a hack and must be removed after the competition. +# +# Default value is [false] +#ignoreStringLiterals=false + +# +# Timeout for specific concrete execution (in milliseconds). +# +# Default value is [1000] +#concreteExecutionDefaultTimeoutInInstrumentedProcessMillis=1000 + +# +# Enable taint analysis or not. +# +# Default value is [false] +#useTaintAnalysis=false + +# +# Path to custom log4j2 configuration file for EngineProcess. +# By default utbot-intellij/src/main/resources/log4j2.xml is used. +# Also default value is used if provided value is not a file. +#engineProcessLogConfigFile="" + +# +# The property is useful only for the IntelliJ IDEs. +# If the property is set in true the engine process opens a debug port. +# @see runInstrumentedProcessWithDebug +# @see org.utbot.intellij.plugin.process.EngineProcess +# +# Default value is [false] +#runEngineProcessWithDebug=false + +# +# The engine process JDWP agent's port of the engine process. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5005] +#engineProcessDebugPort=5005 + +# +# Value of the suspend mode for the JDWP agent of the engine process. +# If the value is true, the engine process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendEngineProcessExecutionInDebugMode=true + +# +# The property is useful only for the IntelliJ IDEs. +# If the property is set in true the spring analyzer process opens a debug port. +# @see runInstrumentedProcessWithDebug +# @see org.utbot.spring.process.SpringAnalyzerProcess +# +# Default value is [false] +#runSpringAnalyzerProcessWithDebug=false + +# +# The spring analyzer process JDWP agent's port. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5007] +#springAnalyzerProcessDebugPort=5007 + +# +# Value of the suspend mode for the JDWP agent of the spring analyzer process. +# If the value is true, the spring analyzer process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendSpringAnalyzerProcessExecutionInDebugMode=true + +# +# The instrumented process JDWP agent's port of the instrumented process. +# A debugger attaches to the port in order to debug the process. +# +# Default value is [5006] +#instrumentedProcessDebugPort=5006 + +# +# Value of the suspend mode for the JDWP agent of the instrumented process. +# If the value is true, the instrumented process will suspend until a debugger attaches to it. +# +# Default value is [true] +#suspendInstrumentedProcessExecutionInDebugMode=true + +# +# If true, runs the instrumented process with the ability to attach a debugger. +# To debug the instrumented process, set the breakpoint in the +# [org.utbot.instrumentation.rd.InstrumentedProcess.Companion.invoke] +# and in the instrumented process's main function and run the main process. +# Then run the remote JVM debug configuration in IDEA. +# If you see the message in console about successful connection, then +# the debugger is attached successfully. +# Now you can put the breakpoints in the instrumented process and debug +# both processes simultaneously. +# @see [org.utbot.instrumentation.rd.InstrumentedProcess.Companion.invoke] +# +# Default value is [false] +#runInstrumentedProcessWithDebug=false + +# +# Number of branch instructions using for clustering executions in the test minimization phase. +# +# Default value is [4] +#numberOfBranchInstructionsForClustering=4 + +# +# Determines should we choose only one crash execution with "minimal" model or keep all. +# +# Default value is [true] +#minimizeCrashExecutions=true + +# +# Enable it to calculate unsat cores for hard constraints as well. +# It may be usefull during debug. +# Note: it might highly impact performance, so do not enable it in release mode. +# +# Default value is [false] +#enableUnsatCoreCalculationForHardConstraints=false + +# +# Enable it to process states with unknown solver status +# from the queue to concrete execution. +# +# Default value is [true] +#processUnknownStatesDuringConcreteExecution=true + +# +# 2^{this} will be the length of observed subpath. +# See [SubpathGuidedSelector] +# +# Default value is [1] +#subpathGuidedSelectorIndex=1 + +# +# Flag that indicates whether feature processing for execution states enabled or not +# +# Default value is [false] +#enableFeatureProcess=false + +# +# Path to deserialized ML models +# +# Default value is [../models/0] +#modelPath=../models/0 + +# +# Full class name of the class containing the configuration for the ML models to solve path selection task. +# +# Default value is [org.utbot.AnalyticsConfiguration] +#analyticsConfigurationClassPath=org.utbot.AnalyticsConfiguration + +# +# Full class name of the class containing the configuration for the ML models exported from the PyTorch to solve path selection task. +# +# Default value is [org.utbot.AnalyticsTorchConfiguration] +#analyticsTorchConfigurationClassPath=org.utbot.AnalyticsTorchConfiguration + +# +# Number of model iterations that will be used during ContestEstimator +# +# Default value is [1] +#iterations=1 + +# +# Path for state features dir +# +# Default value is [eval/secondFeatures/antlr/INHERITORS_SELECTOR] +#featurePath=eval/secondFeatures/antlr/INHERITORS_SELECTOR + +# +# Counter for tests during testGeneration for one project in ContestEstimator +# +# Default value is [0] +#testCounter=0 + +# +# Flag that indicates whether tests for synthetic (see [Executable.isSynthetic]) and implicitly declared methods (like values, valueOf in enums) should be generated, or not +# +# Default value is [true] +#skipTestGenerationForSyntheticAndImplicitlyDeclaredMethods=true + +# +# Flag that indicates whether should we branch on and set static fields from trusted libraries or not. +# @see [org.utbot.common.WorkaroundReason.IGNORE_STATICS_FROM_TRUSTED_LIBRARIES] +# +# Default value is [true] +#ignoreStaticsFromTrustedLibraries=true + +# +# Use the sandbox in the instrumented process. +# If true, the sandbox will prevent potentially dangerous calls, e.g., file access, reading +# or modifying the environment, calls to `Unsafe` methods etc. +# If false, all these operations will be enabled and may lead to data loss during code analysis +# and test generation. +# +# Default value is [true] +#useSandbox=true + +# +# Transform bytecode in the instrumented process. +# If true, bytecode transformation will help fuzzing to find interesting input data, but the size of bytecode can increase. +# If false, bytecode won`t be changed. +# +# Default value is [false] +#useBytecodeTransformation=false + +# +# Limit for number of generated tests per method (in each region) +# +# Default value is [50] +#maxTestsPerMethodInRegion=50 + +# +# Max file length for generated test file +# +# Default value is [1000000] +#maxTestFileSize=1000000 + +# +# If this options set in true, all soot classes will be removed from a Soot Scene, +# therefore, you will be unable to test soot classes. +# +# Default value is [true] +#removeSootClassesFromHierarchy=true + +# +# If this options set in true, all UtBot classes will be removed from a Soot Scene, +# therefore, you will be unable to test UtBot classes. +# +# Default value is [true] +#removeUtBotClassesFromHierarchy=true + +# +# Use this option to enable calculation and logging of MD5 for dropped states by statistics. +# Example of such logging: +# Dropping state (lastStatus=UNDEFINED) by the distance statistics. MD5: 5d0bccc242e87d53578ca0ef64aa5864 +# +# Default value is [false] +#enableLoggingForDroppedStates=false + +# +# If this option set in true, depending on the number of possible types for +# a particular object will be used either type system based on conjunction +# or on bit vectors. +# @see useBitVecBasedTypeSystem +# +# Default value is [true] +#useBitVecBasedTypeSystem=true + +# +# The number of types on which the choice of the type system depends. +# +# Default value is [64] +#maxTypeNumberForEnumeration=64 + +# +# The threshold for numbers of types for which they will be encoded into solver. +# It is used to do not encode big type storages due to significand performance degradation. +# +# Default value is [512] +#maxNumberOfTypesToEncode=512 + +# +# The behaviour of further analysis if tests generation cancellation is requested. +# +# NONE: Do not react on cancellation +# CANCEL_EVERYTHING: Clear all generated test classes +# SAVE_PROCESSED_RESULTS: Show already processed test classes +# +# Default value is [SAVE_PROCESSED_RESULTS] +#cancellationStrategyType=SAVE_PROCESSED_RESULTS + +# +# Depending on this option, sections might be analyzed or not. +# Note that some clinit sections still will be initialized using runtime information. +# +# Default value is [true] +#enableClinitSectionsAnalysis=true + +# +# Process all clinit sections concretely. +# If [enableClinitSectionsAnalysis] is false, it disables effect of this option as well. +# Note that values processed concretely won't be replaced with unbounded symbolic variables. +# +# Default value is [false] +#processAllClinitSectionsConcretely=false + +# +# In cases where we don't have a body for a method, we can either throw an exception +# or treat this a method as a source of an unbounded symbolic variable returned as a result. +# If this option is set in true, instead of analysis we will return an unbounded symbolic +# variable with a corresponding type. Otherwise, an exception will be thrown. +# Default value is false since it is not a common situation when you cannot retrieve a body +# from a regular method. Setting this option in true might be suitable in situations when +# it is more important not to fall at all rather than work precisely. +#treatAbsentMethodsAsUnboundedValue=false + +# +# A maximum size for any array in the program. Note that input arrays might be less than this value +# due to the symbolic engine limitation, see `org.utbot.engine.Traverser.softMaxArraySize`. +# +# Default value is [1024] +#maxArraySize=1024 + +# +# A maximum size for any array in the program. Note that input arrays might be less than this value +# due to the symbolic engine limitation, see `org.utbot.engine.Traverser.softMaxArraySize`. +# +# Default value is [false] +#disableUnsatChecking=false + +# +# When generating integration tests we only partially reset context in between executions to save time. +# For example, entity id generators do not get reset. It may lead to non-reproduceable results if +# IDs leak to the output of the method under test. +# To cope with that, we rerun executions that are left after minimization, fully resetting Spring context +# between executions. However, full context reset is slow, so we use this setting to limit number of +# tests per method that are rerun with full context reset in case minimization outputs too many tests. +# +# Default value is [25] +#maxSpringContextResetsPerMethod=25 From 4a40ff7dfbc0853e042fc7c8d3caaec62f1a8c47 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Thu, 9 Nov 2023 18:02:43 +0300 Subject: [PATCH 2/5] Update plugin.xml and build on github script --- .github/workflows/publish-plugin-from-branch.yml | 11 +++++++---- .../src/main/resources/META-INF/plugin.xml | 5 ----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-plugin-from-branch.yml b/.github/workflows/publish-plugin-from-branch.yml index b6c191deb9..e6857b9656 100644 --- a/.github/workflows/publish-plugin-from-branch.yml +++ b/.github/workflows/publish-plugin-from-branch.yml @@ -46,10 +46,13 @@ jobs: configuration: - plugin_type: IC extra_options: "-PideType=IC -PprojectType=Community" + directory: utbot-intellij-main - plugin_type: IU extra_options: "-PideType=IU -PprojectType=Ultimate" + directory: utbot-intellij-main - plugin_type: PY extra_options: "-PideType=PY -PprojectType=Ultimate" + directory: utbot-intellij-python runs-on: ubuntu-20.04 container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: @@ -81,13 +84,13 @@ jobs: - name: Build UTBot IntelliJ IDEA plugin run: | gradle clean buildPlugin --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} - cd utbot-intellij-main/build/distributions - unzip utbot-intellij-main-${{ env.VERSION }}.zip - rm utbot-intellij-main-${{ env.VERSION }}.zip + cd ${{ matrix.configuration.directory }}/build/distributions + unzip ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip + rm ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip - name: Archive UTBot IntelliJ IDEA plugin if: ${{ inputs.upload-artifact == 'true' }} uses: actions/upload-artifact@v3 with: name: utbot-intellij-${{ matrix.configuration.plugin_type }}-${{ env.VERSION_ARCHIVE }} - path: utbot-intellij-main/build/distributions/* + path: ${{ matrix.configuration.directory }}/build/distributions/* diff --git a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml index 39ed71a602..ce7a275fc5 100644 --- a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml @@ -48,9 +48,4 @@ Have an idea? Start a discussion. ]]> - - - From 0e7dbea6b0d1cdde4d94b406f47c438117f3c2e1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 10 Nov 2023 11:49:51 +0300 Subject: [PATCH 3/5] Fix plugin.xml --- utbot-intellij-python/src/main/resources/META-INF/plugin.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml index ce7a275fc5..bb8000ef1a 100644 --- a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml @@ -2,7 +2,7 @@ org.utbot.pycharm - UnitTestBot Pycharm + UnitTestBot PyCharm utbot.org com.intellij.modules.platform @@ -24,7 +24,6 @@ id="org.utbot.intellij.plugin.settings.Configurable" displayName="UnitTestBot"/> - From 6c8372ee42b01f6f73e5763b59977ee19b2a455a Mon Sep 17 00:00:00 2001 From: Vyacheslav Tamarin Date: Fri, 10 Nov 2023 17:39:01 +0300 Subject: [PATCH 4/5] Add minimal version checker --- .../plugin/python/PythonDialogProcessor.kt | 27 ++++++++++++------- .../python/utils/PythonVersionChecker.kt | 22 +++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 utbot-python/src/main/kotlin/org/utbot/python/utils/PythonVersionChecker.kt diff --git a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt index 86eb6b4d56..a90e62650e 100644 --- a/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt +++ b/utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt @@ -36,6 +36,7 @@ import org.utbot.python.TestFileInformation import org.utbot.python.framework.api.python.PythonClassId import org.utbot.python.framework.codegen.PythonCgLanguageAssistant import org.utbot.python.newtyping.mypy.dropInitFile +import org.utbot.python.utils.PythonVersionChecker import java.util.concurrent.ScheduledFuture import java.util.concurrent.TimeUnit import kotlin.io.path.Path @@ -124,16 +125,24 @@ object PythonDialogProcessor { title = "Python test generation error" ) } else { - val dialog = createDialog( - project, - elementsToShow, - focusedElement, - pythonPath, - ) - if (!dialog.showAndGet()) { - return + if (!PythonVersionChecker.checkPythonVersion(pythonPath)) { + showErrorDialogLater( + project, + message = "Please use Python 3.10 or newer", + title = "Python test generation error" + ) + } else { + val dialog = createDialog( + project, + elementsToShow, + focusedElement, + pythonPath, + ) + if (!dialog.showAndGet()) { + return + } + createTests(project, dialog.model) } - createTests(project, dialog.model) } } diff --git a/utbot-python/src/main/kotlin/org/utbot/python/utils/PythonVersionChecker.kt b/utbot-python/src/main/kotlin/org/utbot/python/utils/PythonVersionChecker.kt new file mode 100644 index 0000000000..a0e81e7a07 --- /dev/null +++ b/utbot-python/src/main/kotlin/org/utbot/python/utils/PythonVersionChecker.kt @@ -0,0 +1,22 @@ +package org.utbot.python.utils + +object PythonVersionChecker { + private val minimalPythonVersion = Triple(3, 10, 0) + + fun checkPythonVersion(pythonPath: String): Boolean { + try { + val version = runCommand(listOf( + pythonPath, + "-c", + "\"import sys; print('.'.join(map(str, sys.version_info[:3])))\"" + )) + if (version.exitValue == 0) { + val (major, minor, patch) = version.stdout.split(".") + return (major.toInt() >= minimalPythonVersion.first && minor.toInt() >= minimalPythonVersion.second && patch.toInt() >= minimalPythonVersion.third) + } + return false + } catch (_: Exception) { + return false + } + } +} \ No newline at end of file From cc7709aba7dfba1b78bb7fc9348c1d1e89763ba6 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Mon, 11 Dec 2023 16:52:47 +0300 Subject: [PATCH 5/5] Fix ID and name for Python-specific plugin --- utbot-intellij-python/src/main/resources/META-INF/plugin.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml index bb8000ef1a..129a191882 100644 --- a/utbot-intellij-python/src/main/resources/META-INF/plugin.xml +++ b/utbot-intellij-python/src/main/resources/META-INF/plugin.xml @@ -1,8 +1,8 @@ - org.utbot.pycharm - UnitTestBot PyCharm + org.utbot.python + UnitTestBot for Python utbot.org com.intellij.modules.platform