Tk Source Code

View Ticket
Login
Ticket UUID: 900a8ec11a9b3d4fb969b50b3d9ac198c87f10e1
Title: Error running test file ttk/treeview.test
Type: Bug Version: 9.1b0
Submitter: erikleunissen Created on: 2026-07-21 12:09:44
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-08-28 11:43:26
Resolution: Fixed Closed By: erikleunissen
    Closed on: 2026-08-28 11:43:26
Description:
When selecting the test file ttk/treeview.test using the tcltest option "-file",
the process spits:

        Test file error: invalid command name "test"

Sample invocation (for unix based platforms):

        TESTFLAGS="-file treeview.test" make test


This problem has been introduced by commit [ea378fca79].


Additional observation:

The testfile ignores the entire test file initialization (+ structure) that
is common for all Tk test files, which was present before that commit.

Ignoring that is expected to lead to more issues when the test file
is selected as the only one (or as the first one) to be run. This is because
it bypasses the common setup in main.tcl, which in turn loads the files
constraints.tcl and testutils.tcl. It breaks a coherence that is needed
for future efforts to make the test suite more maintainable / verifiable
through the utilities in testutils.tcl.
User Comments: erikleunissen added on 2026-08-28 11:43:26:
Ticket for the test failures observed under MS Windows: [b174f151bb].

erikleunissen added on 2026-08-28 11:36:20:
OK. I've got the other platforms covered: they don't exhibit new test failures with branch
treeview_test_improvements.

I'm seeing something strange though: I DO get test failures when run under MS Windows 11,
which also exhibit when run with current trunk.

What's remarkable is that you (@bohagan, Brian), or anyone lese for that matter,
don't see such test failures when running the tests on MS Windows. Maybe it matters
that my Tk binaries are (cross-)compiled with gcc.

Because you don't report any test failures on MS Windows, and because
I don't see any test failures on the other platforms, I'm going to:

- merge the changes in branch "treeview_test_improvements" into trunk.
- report my observed test failures on MS Windows in a separate ticket: [].

Merge into trunk now completed.
Ticket closed.

bohagan added on 2026-08-23 20:13:28:
I just ran it on Windows and didn't see any test failures. Can't speak
for other platforms, so no objections from me.

erikleunissen added on 2026-08-21 18:13:17:
I'm done adding my proposed improvements to branch treeview_test_improvements,
and I welcome review.

@Brian: I'm specifically inviting you to exercise (the changes on) that branch,
        and share your experiences.

erikleunissen added on 2026-08-21 11:46:10:
I've opened a new branch "treeview_test_improvements" for improvements to
the test file ttk/treeview.test that I suggested earlier (and some more
that are related/implied). See commit [f031b73cb2].

erikleunissen added on 2026-08-19 14:51:13:
The changes made by Brian fix the problem as reported.
(The test file now initializes correctly, tests/main.tcl is imported.)

As I wrote earlier in this ticket, there is some additional opportunity for
improvement left. This is some low-hanging fruit (to me at least) that is partly
associated with the cause of the reported problem (not taking advantage ofthe 
benefits that tests/main.tcl offers in turn).

By his latest post, Brian expressed his intention to look into this later at
his own convenience, and I didn't want to interfere with that intention. But 
if so desired/agreed, I can submit a patch (or even a branch) that contains
these remaining improvements. But I wouldn't want to overtake Brian's intention
just like that.

jan.nijtmans added on 2026-08-19 09:30:03:

Erik, are the [35b3cfeec2d1827c|latest changes] satisfactory for you? Do you have additional remarks? Or can this ticket be closed?

Thanks for all the work (both of you)!


erikleunissen added on 2026-07-28 11:07:14:
Thanks for your point of clarification.

The merge that happened with commit [ea378fca79] disregarded/overlooked the changes
to all test files that had been applied to trunk earlier. These changes ought
have been included into the developent branch for the enhanced treeview before
executing that merge.

Just because you took on the work in the present ticket (and because I seem to
remember that you have been working on the the development branch for the
enhanced treeview), I presumed that you were partly responsible for that neglect.
I'm sorry for any occasions in this ticket where this logical short-circuit
resulted in me addressing you unfairly in this respect.

bohagan added on 2026-07-28 01:51:52:
I made the necessary changes in commit [35b3cfeec2d1827c].

As a point of clarification, I did not make these changes in [ea378fca79],
that's just when the Enhanced Treeview branch was merged into trunk. The
file was originally created during my development which was based on the Tk
9.0 beta release and completely replaced the old test file. That was before
your work on the test reform. So I didn't remove your changes, they were not
in test file to begin with. That's also why I don't use your constraints.tcl
or testutils.tcl file. I'll have to review those files to see what could be
replaced here when I have some time.

For a few of the other comments, I copied the header from the tags file, but
missed making that edit. It's fixed now. The update/wait was leftover from
making it work on all platforms. Windows doesn't work the same as Unix, so it
took a while to find the right combination that worked. So, I'm not inclined
to change it until the changes are proven to work on all platforms. The
second use of focus is not a duplicate.

erikleunissen added on 2026-07-27 12:57:31:
Another observation:

The title in the header of the test file was previously:

    "ttk::treeview widget tests"

It is now:

    "Tests for tags in the ttk::treeview widget"

which is the same as the title in the test file treetags.test

Is this correct?

erikleunissen added on 2026-07-27 09:55:00:
Actually, regarding:

* proc ButtonPress holds two cases where the sequence "update" - "update idletasks"
  is followed by "wait 25". Waiting using "wait" (or "pause") lets events
  being processed in the meantime. Therefore, in general, the calls to "update"
  and "update idletasks" immediately preceding "wait" seem to be useless.

I'm wondering why the waiting ("wait 25") is needed. On my Linux and macOS
boxes, the tests PASS if the sequence of:

    update
    update idletasks
    wait 25

is collapsed into just a single "update".

erikleunissen added on 2026-07-27 09:04:29:
I confirm that the issue for the present ticket has been fixed.

Also, I see that the test file now conforms more to the common structure for
Tk test files, and that the text in the NOTES section has been improved/corrected.
All very good. Thanks very much.

I've taken the liberty of looking into the test file beyond the reported issue,
and saw several more aspects that can be improved upon:

Structural suggestions
----------------------
* the constraints in lines 35-42 aren't test constraints (see man tcltest
  and the file constraints.tcl for examples). Suggestion: collect these
  lines in a test section "COMMON TEST SETUP". The lines 48-51 can be moved
  there as well, and the whole section "COMMON TEST SETUP" can then be moved
  after the section "LOCAL UTILITY PROCS" to let it precede the "TESTS" section
  immediately.
* the point where the first test starts should be marked with a section header
  "TESTS".
* There is opportunity to mark a few more sections in between tests as
 "COMMON TEST SETUP": see around lines 1868, 2436, 2526, 7834, 8036
* test Style-5.10 could benefit from some indentation cleanup

Tk and test-suite-technical suggestions
---------------------------------------
* the local utility proc "wait" is a functional duplicate of proc "pause",
  which is made available to test authors through the testutils mechanism.
  So you could simply remove the proc definition and replace the calls
  "wait ms" by "pause ms".
* there are several cases where "update idletasks" immediately follows upon
  "update". Since "update" already includes an update of idle tasks
  (as the very last thing, see man update), there is undesired redundancy here.
  The command "update idletasks" can simply be removed.
* proc ButtonPress holds two cases where the sequence "update" - "update idletasks"
  is followed by "wait 25". Waiting using "wait" (or "pause") lets events
  being processed in the meantime. Therefore, in general, the calls to "update"
  and "update idletasks" immediately preceding "wait" seem to be useless.
* That same proc holds two calls to "focus -force $w". Can the second one
  be removed?

These last three suggestions need verification by executing the test file on
the various platforms. I'm saying this because there are rare, intricate cases
of timing issues where such redundant constructs may be justified. Maybe you
intended to address exactly such intricate cases (but then that'd better be
explicitly explained in a comment).

bohagan added on 2026-07-27 01:56:40:
Should be fixed now in [541497741c536a32]. Please verify. Thanks.