From dc81683bb7d82bb380ac0f59ab1f6fb80e0f274a Mon Sep 17 00:00:00 2001 From: timor Date: Wed, 26 May 2021 20:13:29 +0200 Subject: [PATCH] vocabs.refresh: Add variants of refresh(-all) that run unit-tests Bound to Shift-F2 per default in the UI Tools windows. --- basis/tools/test/test-docs.factor | 12 +++++++++++- basis/tools/test/test.factor | 6 +++++- basis/ui/tools/tools.factor | 5 ++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/basis/tools/test/test-docs.factor b/basis/tools/test/test-docs.factor index 9253d251f9..428b9aa165 100644 --- a/basis/tools/test/test-docs.factor +++ b/basis/tools/test/test-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax kernel quotations io ; +USING: help.markup help.syntax kernel quotations io strings vocabs.refresh ; IN: tools.test ARTICLE: "tools.test" "Unit testing" @@ -83,6 +83,16 @@ HELP: test HELP: test-all { $description "Runs unit tests for all loaded vocabularies." } ; +HELP: refresh-and-test +{ $values { "prefix" string } } +{ $description "Like " { $link refresh } ", but runs unit tests for all reloaded vocabularies afterwards." } ; + +HELP: refresh-and-test-all +{ $values { "prefix" string } } +{ $description "Like " { $link refresh-all } ", but runs unit tests for all reloaded vocabularies afterwards." } ; + +{ refresh-and-test refresh-and-test-all } related-words + HELP: :test-failures { $description "Prints all pending unit test failures." } ; diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index 2bb5a380c1..38769d880c 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -8,7 +8,7 @@ sequences.generalizations source-files source-files.errors source-files.errors.debugger splitting stack-checker summary system tools.errors tools.time unicode vocabs vocabs.files vocabs.hierarchy vocabs.hierarchy.private vocabs.loader -vocabs.metadata vocabs.parser words ; +vocabs.metadata vocabs.parser vocabs.refresh words ; IN: tools.test TUPLE: test-failure < source-file-error continuation ; @@ -226,6 +226,10 @@ M: test-failure error. ( error -- ) : test-all ( -- ) "" test ; +: refresh-and-test ( prefix -- ) to-refresh [ do-refresh ] keepdd test-vocabs ; + +: refresh-and-test-all ( -- ) "" refresh-and-test ; + : test-main ( -- ) command-line get [ dup vocab-roots get member? [ diff --git a/basis/ui/tools/tools.factor b/basis/ui/tools/tools.factor index ed7ea6f6c0..3a27e02497 100644 --- a/basis/ui/tools/tools.factor +++ b/basis/ui/tools/tools.factor @@ -1,12 +1,14 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel literals memory namespaces sequences system ui +USING: kernel literals memory namespaces sequences system +tools.test ui ui.backend ui.commands ui.gestures ui.tools.browser ui.tools.common ui.tools.error-list ui.tools.listener vocabs.refresh ; IN: ui.tools \ refresh-all H{ { +nullary+ t } { +listener+ t } } define-command +\ refresh-and-test-all H{ { +nullary+ t } { +listener+ t } } define-command \ save H{ { +nullary+ t } } define-command @@ -25,6 +27,7 @@ tool "common" f { { T{ key-down f ${ os macosx? M+ C+ ? } "w" } close-window } { T{ key-down f ${ os macosx? M+ C+ ? } "q" } com-exit } { T{ key-down f f "F2" } refresh-all } + { T{ key-down f { S+ } "F2" } refresh-and-test-all } { T{ key-down f f "F3" } show-error-list } } os macosx? { { T{ key-down f { C+ M+ } "f" } toggle-fullscreen } -- 2.34.1