Testing
test_g_finalize and test_g_finalize_join were responses to Thomas's compatibility concerns. I worked on these two tests for several days before realizing that these tests weren't the whole story!
The very first test case in test_g_finalize_join shows the problem. g.finalize('a.py') must return an absolute path relative to os.getcwd(), not the directory containing the outline! In other words, the callers of g.finalize_join are responsible for specifying the absolute path.
The PR lists all the places where arguments to these functions have changed. The PR's correctness depends on just those places.
Compatibility
Thomas suggested that better docstrings would help. I have just added improved docstrings for the two new functions. However, the code itself is likely easier to understand than the words.
I have given careful thought to the question of retaining the legacy code. I have chosen not to do so. There is no plausible scenario in which the legacy code could be superior to the new code.
Summary
Imo, Leo would be better off with the new code. This PR might cause compatibility problems, but the likelihood is small.
I plan to merge the new code in a few days, but I'll wait for Thomas and Félix to comment first. There is no rush. All comments are welcome.
[...]
Testing
test_g_finalize and test_g_finalize_join were responses to Thomas's compatibility concerns. I worked on these two tests for several days before realizing that these tests weren't the whole story!
The very first test case in test_g_finalize_join shows the problem. g.finalize('a.py') must return an absolute path relative to os.getcwd(), not the directory containing the outline! In other words, the callers of g.finalize_join are responsible for specifying the absolute path.
On Thursday, April 13, 2023 at 9:32:36 AM UTC-4 Edward K. Ream wrote:[...]Testing
test_g_finalize and test_g_finalize_join were responses to Thomas's compatibility concerns. I worked on these two tests for several days before realizing that these tests weren't the whole story!
The very first test case in test_g_finalize_join shows the problem. g.finalize('a.py') must return an absolute path relative to os.getcwd(), not the directory containing the outline! In other words, the callers of g.finalize_join are responsible for specifying the absolute path.
I don't think that this agrees with my understanding of how things have worked in the past. Please correct me if it's not so.1. Paths in at-files should *not* depend on os.getcwd() because that value is state-dependent and is not necessarily defined only by the current outline. The user may have run various scripts that changed it. This could lead to changing and unpredictable locations for external files.2. When I create an external file like this, I expect its path to be relative to the *outline*:@file special/good.py3. When I use an @path node like this, I expect the at file to be located at a path which starts with the @path expression:@path special@file good.py # Path should be special/good.py relative to the outline.4. Since the @path expression is to be prepended to the at-file path, if the @path is an absolute path, the at-file path should be absolute, not relative to the outline.
Or maybe I misunderstood and the references to os.cwd() only refer to the unit tests and not to how the paths are constructed when used in an outline?