From 807bbf2f5649af501f9403eca2bee07f55082163 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 06:06:11 +0000 Subject: [PATCH 1/3] Do not record recent files in test mode (#50) Running the integration tests (and any USE run with -t) opened files via the shell, which pushed them onto the user's recent files list and pushed out the user's own entries. RecentItems.push now returns early when Options.testMode is set, so no recent items are recorded while USE runs in test mode. The recent files (stored in the user's preferences) are therefore left untouched by the test suite. The spec-file push in the launchers was already guarded this way; this covers the remaining path (the shell "open" command). Adds RecentItemsTest verifying push is ignored in test mode and still records otherwise. https://claude.ai/code/session_01A85dAvTAvi2oWkGZH6REEq --- .../java/org/tzi/use/config/RecentItems.java | 7 ++ .../org/tzi/use/config/RecentItemsTest.java | 82 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java diff --git a/use-core/src/main/java/org/tzi/use/config/RecentItems.java b/use-core/src/main/java/org/tzi/use/config/RecentItems.java index 5986ab129..9a25e74ac 100644 --- a/use-core/src/main/java/org/tzi/use/config/RecentItems.java +++ b/use-core/src/main/java/org/tzi/use/config/RecentItems.java @@ -54,6 +54,13 @@ public RecentItems(int maxItems, Preferences prefNode) public void push(String item) { + // Issue #50: while USE runs in test mode (the -t argument), e.g. during + // integration tests, opened files must not be recorded as recent items, + // otherwise they would push out the user's own entries. + if (Options.testMode) { + return; + } + m_items.remove(item); m_items.add(0, item); diff --git a/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java new file mode 100644 index 000000000..c45affbaa --- /dev/null +++ b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java @@ -0,0 +1,82 @@ +/* + * USE - UML based specification environment + * Copyright (C) 1999-2012 Mark Richters, University of Bremen + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.tzi.use.config; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Tests that recent items are not recorded while USE runs in test mode. + * + *

When integration tests run, the files they open must not be added to the + * user's recent files list, otherwise they would push out the user's own + * entries (issue #50). This is controlled by {@link Options#testMode}.

+ * + * @author Claude + */ +public class RecentItemsTest { + + /** An isolated preferences node, kept separate from the real recent files. */ + private Preferences node; + + @BeforeEach + public void setUp() throws BackingStoreException { + Options.resetOptions(); + node = Preferences.userRoot().node("/org/tzi/use/test/recentitems"); + node.clear(); + } + + @AfterEach + public void tearDown() throws BackingStoreException { + node.clear(); + Options.resetOptions(); + } + + @Test + public void pushIsIgnoredInTestMode() { + RecentItems items = new RecentItems(5, node); + assertTrue(items.isEmpty(), "precondition: no recent items"); + + Options.testMode = true; + items.push("/tmp/integration-test-file.use"); + + assertTrue(items.isEmpty(), + "In test mode, opening files must not be recorded as recent items."); + } + + @Test + public void pushRecordsWhenNotInTestMode() { + RecentItems items = new RecentItems(5, node); + + Options.testMode = false; + items.push("/tmp/user-file.use"); + + assertEquals(1, items.size(), + "Outside test mode, recent items must still be recorded as before."); + assertEquals("/tmp/user-file.use", items.peek()); + } +} From 5b2755010bafcf1c2f08373163f91f6e275705a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 06:32:17 +0000 Subject: [PATCH 2/3] Use the project's current copyright notice on new files; drop @author tag --- use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java index c45affbaa..87857f99d 100644 --- a/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java +++ b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java @@ -1,6 +1,6 @@ /* * USE - UML based specification environment - * Copyright (C) 1999-2012 Mark Richters, University of Bremen + * Copyright (C) 1999-2025 University of Bremen & University of Applied Sciences Hamburg * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -36,7 +36,6 @@ * user's recent files list, otherwise they would push out the user's own * entries (issue #50). This is controlled by {@link Options#testMode}.

* - * @author Claude */ public class RecentItemsTest { From d8264a77d3fbd94a87f089aa1d6595ce899c9013 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 06:40:16 +0000 Subject: [PATCH 3/3] Add @author tags and bump copyright year to 2026 on new files Add @author Cansin Yildiz and @author Claude to the files added in this branch, and update the copyright year to 1999-2026. Co-authored-by: Claude https://claude.ai/code/session_01A85dAvTAvi2oWkGZH6REEq --- .../src/test/java/org/tzi/use/config/RecentItemsTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java index 87857f99d..343fc170f 100644 --- a/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java +++ b/use-core/src/test/java/org/tzi/use/config/RecentItemsTest.java @@ -1,6 +1,6 @@ /* * USE - UML based specification environment - * Copyright (C) 1999-2025 University of Bremen & University of Applied Sciences Hamburg + * Copyright (C) 1999-2026 University of Bremen & University of Applied Sciences Hamburg * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -36,6 +36,8 @@ * user's recent files list, otherwise they would push out the user's own * entries (issue #50). This is controlled by {@link Options#testMode}.

* + * @author Cansin Yildiz + * @author Claude */ public class RecentItemsTest {