README.md
1Manual tests for pull request #1637, which fixes issue #214.
2
3There are 4 'good' tests, which should render with no errors,
4and 4 'bad' tests, which should fail with an error message.
5The tests should be run both using the CLI, and using the GUI.
6
7TODO: These tests should be automated.
8
91. Relative pathnames
10
11The code that handles relative pathnames in import() statements has
12been refactored, so test it. (Imported files are found relative to the directory
13containing the script that performs the import, which may be different from
14the directory containing the "root" script file, as in the case where A.scad
15uses B.scad, which in turn imports an STL file.
16
17Part of the pathname resolution code is different between the command line
18case and the interactive GUI case, and both versions of this code were changed,
19so it's necessary to test both cases.
20
212. Syntax errors in the presence of `include`
22
23The actual bug fix is that, when a syntax error is encountered, we report
24the file name and the correct line number. Previously,
25* No file name was reported, which creates a problem if the syntax error was
26 actually in an included file.
27* The reported line number could be incorrect if the script uses `include`.
28
293. Run the tests
30
31To run the tests using the CLI,
32use this shell script:
33```
34scad=<pathname of project root>/openscad
35for f in [gb]*.scad; do echo $f; $scad -o ,.stl $f; done
36```
37
38And here's the output:
39```
40bad-include-synerr.scad
41ERROR: Parser error in file "/res/doug/src/openscad/testdata/manual/issue214/syntax-error-in-line-2.scad", line 2: syntax error
42
43Can't parse file 'bad-include-synerr.scad'!
44
45bad-includeX.scad
46WARNING: Can't open import file '"cube.stl"'.
47Current top level object is empty.
48bad-synerr.scad
49ERROR: Parser error in file "/res/doug/src/openscad/testdata/manual/issue214/bad-synerr.scad", line 3: syntax error
50
51Can't parse file 'bad-synerr.scad'!
52
53bad-useX2.scad
54DEPRECATED: Imported file (cube2.stl) found in document root instead of relative to the importing module. This behavior is deprecated
55good-include2.scad
56good-includeX2.scad
57good-use2.scad
58good-useX.scad
59```
60
61I'm testing a bunch of combinations of `include` and `use` to make sure that
62pathname interpretation still works as before. Note that `include` and `use`
63use different algorithms for looking up relative pathnames in an `import`
64statement, as reflected in these tests. The behaviour of `include` looks like
65a bug. But, the behaviour is unchanged from before this pull request.
66
67I have two test cases for syntax errors:
68* `bad-include-synerr.scad` tests a syntax error in an included file:
69 the reported filename is the name of the included file,
70 and the line number is correct.
71* `bad-synerr.scad` tests a syntax error in the root script, after including
72 a file that doesn't have a syntax error. The improvement is that the reported
73 line number is correct.
74
75These tests should also be run in the GUI, since different code is involved.
76Use a similar shell script:
77```
78scad=<pathname of project root>/openscad
79for f in [gb]*.scad; do echo $f; $scad $f; done
80```
81This script will open each window one at a time; verify the results then close
82the window, and the next window will pop up.
83