Browse Source

Merge pull request #13003 from Ultimaker/CURA-8792_update_pycharm_run_config

[CURA-8792] Move run configuration templates out of conan-config into this repo.
Jelle Spijker 2 years ago
parent
commit
00d99d10b9

+ 25 - 0
.run_templates/pycharm_cura_run.run.xml.jinja

@@ -0,0 +1,25 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="{{ name }}" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
+    <module name="{{ module_name }}" />
+    <option name="INTERPRETER_OPTIONS" value="" />
+    <option name="PARENT_ENVS" value="true" />
+    <envs>
+      <env name="PYTHONUNBUFFERED" value="1" />{% for key, value in env_vars.items() %}
+      <env name="{{ key }}" value="{{ value }}" />{% endfor %}
+    </envs>
+    <option name="SDK_HOME" value="{{ sdk_path }}" />
+    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+    <option name="IS_MODULE_SDK" value="true" />
+    <option name="ADD_CONTENT_ROOTS" value="true" />
+    <option name="ADD_SOURCE_ROOTS" value="true" />
+    <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
+    <option name="SCRIPT_NAME" value="$PROJECT_DIR$/{{ script_name }}" />
+    <option name="PARAMETERS" value="{{ parameters }}" />
+    <option name="SHOW_COMMAND_LINE" value="false" />
+    <option name="EMULATE_TERMINAL" value="false" />
+    <option name="MODULE_MODE" value="false" />
+    <option name="REDIRECT_INPUT" value="false" />
+    <option name="INPUT_FILE" value="" />
+    <method v="2" />
+  </configuration>
+</component>

+ 23 - 0
.run_templates/pycharm_cura_test.run.xml.jinja

@@ -0,0 +1,23 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="{{ name }}"  type="tests" factoryName="py.test" nameIsGenerated="true">
+    <module name="{{ module_name }}" />
+    <option name="INTERPRETER_OPTIONS" value="" />
+    <option name="PARENT_ENVS" value="true" />
+    <envs>
+      <env name="PYTHONUNBUFFERED" value="1" />{% for key, value in env_vars.items() %}
+      <env name="{{ key }}" value="{{ value }}" />{% endfor %}
+    </envs>
+    <option name="SDK_HOME" value="{{ sdk_path }}" />
+    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
+    <option name="IS_MODULE_SDK" value="true" />
+    <option name="ADD_CONTENT_ROOTS" value="true" />
+    <option name="ADD_SOURCE_ROOTS" value="true" />
+    <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
+    <option name="_new_keywords" value="&quot;&quot;" />
+    <option name="_new_parameters" value="&quot;&quot;" />
+    <option name="_new_additionalArguments" value="&quot;&quot;" />
+    <option name="_new_target" value="&quot;$PROJECT_DIR$/{{ script_name }}&quot;" />
+    <option name="_new_targetType" value="&quot;PATH&quot;" />
+    <method v="2" />
+  </configuration>
+</component>

+ 110 - 0
conandata.yml

@@ -286,3 +286,113 @@
             Windows: "./icons/Cura.ico"
             Macos: "./icons/cura.icns"
             Linux: "./icons/cura-128.png"
+pycharm_targets:
+    - jinja_path: .run_templates/pycharm_cura_run.run.xml.jinja
+      module_name: Cura
+      name: cura
+      script_name: cura_app.py
+    - jinja_path: .run_templates/pycharm_cura_run.run.xml.jinja
+      module_name: Cura
+      name: cura_external_engine
+      parameters: --external-backend
+      script_name: cura_app.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in tests
+      script_name: tests/
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestBuildVolume.py
+      script_name: tests/TestBuildVolume.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestConvexHullDecorator.py
+      script_name: tests/TestConvexHullDecorator.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestCuraSceneNode.py
+      script_name: tests/TestCuraSceneNode.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestCuraSceneNode.py
+      script_name: tests/TestExtruderManager.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestGCodeListDecorator.py
+      script_name: tests/TestGCodeListDecorator.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestIntentManager.py
+      script_name: tests/TestIntentManager.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestLayer.py
+      script_name: tests/TestLayer.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestMachineAction.py
+      script_name: tests/TestMachineAction.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestMachineManager.py
+      script_name: tests/TestMachineManager.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestOAuth2.py
+      script_name: tests/TestOAuth2.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestObjectsModel.py
+      script_name: tests/TestObjectsModel.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestPrintInformation.py
+      script_name: tests/TestPrintInformation.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestProfileRequirements.py
+      script_name: tests/TestProfileRequirements.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestThemes.py
+      script_name: tests/TestThemes.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestContainerManager.py
+      script_name: tests/Settings/TestContainerManager.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestCuraContainerRegistry.py
+      script_name: tests/Settings/TestCuraContainerRegistry.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestCuraStackBuilder.py
+      script_name: tests/Settings/TestCuraStackBuilder.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestDefinitionContainer.py
+      script_name: tests/Settings/TestDefinitionContainer.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestExtruderStack.py
+      script_name: tests/Settings/TestExtruderStack.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestGlobalStack.py
+      script_name: tests/Settings/TestGlobalStack.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestProfiles.py
+      script_name: tests/Settings/TestProfiles.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestSettingInheritanceManager.py
+      script_name: tests/Settings/TestSettingInheritanceManager.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestSettingOverrideDecorator.py
+      script_name: tests/Settings/TestSettingOverrideDecorator.py
+    - jinja_path: .run_templates/pycharm_cura_test.run.xml.jinja
+      module_name: Cura
+      name: pytest in TestSettingVisibilityPresets.py
+      script_name: tests/Settings/TestSettingVisibilityPresets.py

+ 3 - 17
conanfile.py

@@ -1,11 +1,6 @@
 import os
-import sys
 from pathlib import Path
 
-from io import StringIO
-
-from platform import python_version
-
 from jinja2 import Template
 
 from conans import tools
@@ -59,18 +54,9 @@ class CuraConan(ConanFile):
         "revision": "auto"
     }
 
-    # TODO: Add unit tests (but they need a different jinja template
-    _pycharm_targets = [{
-            "name": "cura",
-            "module_name": "Cura",
-            "script_name": "cura_app.py",
-        }, {
-            "name": "cura_external_engine",
-            "module_name": "Cura",
-            "script_name": "cura_app.py",
-            "parameters": "--external-backend"
-        }
-    ]
+    @property
+    def _pycharm_targets(self):
+        return self.conan_data["pycharm_targets"]
 
     # FIXME: These env vars should be defined in the runenv.
     _cura_env = None