kennetek / gridfinity-rebuilt-openscad

A ground-up rebuild of the stock gridfinity bins in OpenSCAD
Other
1.15k stars 166 forks source link

Regression testing #76

Closed Ruudjhuu closed 6 months ago

Ruudjhuu commented 1 year ago

I implemented a start/skeleton/quick idea/POC regarding regression testing. This python implementation is able to test modules individual. This is an answer on my initial post #51. I make too many mistakes when expanding this code base where I do not yet fully understand all calculations. Regression test will help identify if ideas will work and not break other models. The process is as follows:

I developed this on a Linux system with python3.10.9 and would like to know if it also works for Windows. There might be an issue with the use of ".." for a parent directory on Windows. I tried my best to not use external libraries, but I am not yet sure if I succeeded.

Before I create more testcases I would like your opinion on this approach.

To run the tests clone this repo, go inside the folder and execute:

python -m unittest tests/utility_test.py -v

The output should look something like this:

test_cutter_weight (tests.utility_test.BaseplateTest) ... Run with command: openscad --enable fast-csg -o ./openscad_test_22022023_180744/out.stl ./openscad_test_22022023_180744/test.scad
ok
test_block_base_hole_style_0 (tests.utility_test.UtilityTest) ... Run with command: openscad --enable fast-csg -o ./openscad_test_22022023_180744/out.stl ./openscad_test_22022023_180744/test.scad
ok
test_block_base_hole_style_1 (tests.utility_test.UtilityTest) ... Run with command: openscad --enable fast-csg -o ./openscad_test_22022023_180744/out.stl ./openscad_test_22022023_180744/test.scad
ok
test_block_base_hole_style_2 (tests.utility_test.UtilityTest) ... Run with command: openscad --enable fast-csg -o ./openscad_test_22022023_180744/out.stl ./openscad_test_22022023_180744/test.scad
ok
test_block_base_hole_style_3 (tests.utility_test.UtilityTest) ... Run with command: openscad --enable fast-csg -o ./openscad_test_22022023_180744/out.stl ./openscad_test_22022023_180744/test.scad
ok

----------------------------------------------------------------------
Ran 5 tests in 0.374s

OK

When the testcases are going to be expanded, I would also like to introduce running all tests automatically on every pull request.

Let me know what you think.

Ruudjhuu commented 1 year ago

@kennetek Could you please look at this feature (you set minimal reviewers needed to 1, and I can not approve it myself). I really want this feature before developing more features. There is too much hard too follow code in this repo and 1 line change could potentially break 90% of the features without it being notified.

kennetek commented 1 year ago

Well this is overwhelming and very very cool. Do you have anything you want me specifically to look at now? It seems very developed at this point and I probably can't contribute much. Although, I cloned this branch and ran the unit and integration tests, and got 2 and 22 failures respectively. That does not seem like the expected output, but I have no clue.

Ruudjhuu commented 1 year ago

I understand this is overwhelming. The things I would like you to look at are:

A little bit python unittest background: When creating tests, a class should be created containing the tests. All functions in that class beginning with: test_' will be executed as standalone test.setUp()` will be executed before every test defined in that class.

I did not changed the openscad code and made the assumption that all implemented openscad functionality is as expected and should stay that way.

I did already use these tests to validate the regression of bug fixes in other branches I created and to validate pull requests of others. I already prevented breaking some random stuff with the help of these tests. Currently the integration tests are most valuable for bug fixing and sanity checking. Unit/module tests will be valuable for new features and refactoring as they are faster then I'd ever expected.

kennetek commented 1 year ago

After cloning your branch, I tried to run the python scripts again with the 2021 version of OpenSCAD (you were right, I had the unstable build as my main install). However, it does not run as it fails to import open3d. I was not able to use pip to install it, it said module not found despite PyPi saying it should just be pip install open3d. What version of python are you using? Also, shouldn't there be a requirements file that includes open3d and any other libraries you are using?

Ruudjhuu commented 1 year ago

Ah, yes I just added the open3d dependency. Open3d is not available yet for python 3.11. but it should be for 3.7, 3.8, 3.9, and 3.10. The automated tasks on GitHub uses 3.10.

With the open3d dependency it might be possible that the unstable versions of openscad also works. I'm going to test it as we can speed things up with some expirimental features.

Ruudjhuu commented 6 months ago

Not interested anymore in getting this to work.