Skip to content

Commit

Permalink
#24 Add addon as a file support and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaskastle committed Apr 3, 2020
1 parent 9bf27f9 commit 4ca11ee
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ jobs:
cd examples/testing-fake-addon/
python test_addon_blender_prezipped_addon.py fake_addon ${{ matrix.blender-version }}
- name: Test Blender ${{ matrix.blender-version }} x ${{ matrix.os}} built in addon
# This addon does not work with versions of blender below 2.8 and contains
# incompatible code that just crashed blender those versions of blender
#if: startsWith(matrix.blender-version, '2.7') != true
run: |
cd examples/testing-io_scene_obj/
pwd
python test_addon_blender.py io_scene_obj ${{ matrix.blender-version }}
- name: Test Blender ${{ matrix.blender-version }} x ${{ matrix.os}} built in addon file
run: |
cd examples/testing-io_scene_obj/
python test_addon_blender.py io_import_images_as_planes.py ${{ matrix.blender-version }}
- name: Expose coverage as a CI download # Related to test_fake_addon_blender_advanced.py
uses: actions/upload-artifact@v1
with:
Expand Down
11 changes: 7 additions & 4 deletions blender_addon_tester/run_blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _run_blender_with_python_script(blender, blender_python_script):
else:
return 1

def test_exisiting_addons(blender_revision, addon_path, cache, blender):
def test_exisiting_addons(blender_revision, addon_path, blender):
addon = addon_path
rev = re.sub("[a-z]$", "", blender_revision)
if "darwin" == sys.platform:
Expand All @@ -33,6 +33,7 @@ def test_exisiting_addons(blender_revision, addon_path, cache, blender):

loc = f"{loc}/*/{addon}"
files = glob(loc)
print(files)
for addon in files:
zfile = f"{addon}.zip"
zf = zipfile.ZipFile(zfile, "w")
Expand All @@ -45,8 +46,10 @@ def test_exisiting_addons(blender_revision, addon_path, cache, blender):
zf.write(addon)
zf.close()

shutil.rmtree(os.path.realpath(addon))

if os.path.isdir(addon):
shutil.rmtree(os.path.realpath(addon))
else:
os.unlink(os.path.realpath(addon))

def run_blender_version_for_addon_with_pytest_suite(addon_path, blender_revision=None, config={}):
"""
Expand Down Expand Up @@ -119,7 +122,7 @@ def run_blender_version_for_addon_with_pytest_suite(addon_path, blender_revision
else:
os.environ["BLENDER_ADDON_TESTS_PATH"] = config["tests"]

test_exisiting_addons(blender_revision, addon_path, os.environ["BLENDER_CACHE"], blender)
test_exisiting_addons(blender_revision, addon_path, blender)

# Run tests with the proper Blender version and configured tests
return _run_blender_with_python_script(blender, test_file)
Expand Down
40 changes: 40 additions & 0 deletions examples/testing-io_scene_obj/io_import_images_as_planes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

bl_info = {
"name": "Import Images as Planes",
"author": "Florian Meyer (tstscr), mont29, matali, Ted Schundler (SpkyElctrc)",
"version": (3, 3, 0),
"blender": (2, 80, 0),
"location": "File > Import > Images as Planes or Add > Mesh > Images as Planes",
"description": "Imports images and creates planes with the appropriate aspect ratio. "
"The images are mapped to the planes.",
"warning": "",
"doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/images_as_planes.html",
"support": 'OFFICIAL',
"category": "Import-Export",
}

def register():
print("Hello World")


def unregister(): # pragma: no cover
print("Goodbye World")

0 comments on commit 4ca11ee

Please sign in to comment.