From d2a4b35e56f702d5f1dfaf843bf84682ca60b642 Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Sun, 29 Dec 2024 09:58:51 -0500 Subject: [PATCH] cleanup: reduce duplication in module definitions ...by using deft-shared to re-export everything in a way that can be used by the workspaces and pacman modules. --- sources/app-library.dylan | 4 +- sources/library.dylan | 106 +++++++---------------- sources/pacman/install-test.dylan | 8 +- sources/shared.dylan | 2 +- sources/test-suite-library.dylan | 21 ++--- sources/workspaces/workspaces-test.dylan | 2 +- 6 files changed, 44 insertions(+), 99 deletions(-) diff --git a/sources/app-library.dylan b/sources/app-library.dylan index 4ed1ef9..6f70bc0 100644 --- a/sources/app-library.dylan +++ b/sources/app-library.dylan @@ -11,11 +11,11 @@ define library deft-app end library; define module deft-app - use common-dylan; use command-line-parser; + use common-dylan; + use deft-shared; use deft; use format-out; use logging; use operating-system, prefix: "os/"; - use shared; end module; diff --git a/sources/library.dylan b/sources/library.dylan index 7ea82b4..a3a7b10 100644 --- a/sources/library.dylan +++ b/sources/library.dylan @@ -19,21 +19,33 @@ define library deft export deft, - pacman, - %pacman, - shared, - workspaces, - %workspaces; + deft-shared, + pacman, %pacman, + workspaces, %workspaces; end library; -// Definitions used by all the other modules. -define module shared - use format-out; - use operating-system, prefix: "os/"; - use streams; - use strings; - use uncommon-dylan, - exclude: { format-out }; +// Utilities shared by all Deft modules, and also a set of shared imports. +define module deft-shared + use collectors, export: all; + use command-line-parser, export: all; + use date, import: { current-date, }, export: all; + use dylan-extensions, import: { address-of }, export: all; + use file-source-records, prefix: "sr/", export: all; + use file-system, prefix: "fs/", export: all; + use format-out, export: all; + use format, export: all; + use json, export: all; + use locators, export: all; + use operating-system, prefix: "os/", export: all; + use print, export: all; + use regular-expressions, export: all; + use standard-io, export: all; + use streams, export: all; + use strings, export: all; + use threads, import: { dynamic-bind }, export: all; + use uncommon-dylan, export: all; + use uncommon-utils, export: all; + export *debug?*, *verbose?*, @@ -110,26 +122,8 @@ define module pacman end module; define module %pacman - use date, - import: { current-date, }; - use file-system, prefix: "fs/"; - use format; - use format-out; - use json; - use locators; - use operating-system, prefix: "os/"; - use print; - use regular-expressions; - use shared; - use streams; - use strings; - use uncommon-dylan, - exclude: { format-out, format-to-string }; - // Do we need this? - use uncommon-utils, - import: { elt, iff, , value-sequence }; - - use pacman, export: all; + use deft-shared; + use pacman; // For the test suite. export @@ -175,32 +169,12 @@ define module workspaces end module; define module %workspaces - use collectors; - use dylan-extensions, - import: { address-of }; - use file-source-records, prefix: "sr/"; - use file-system, prefix: "fs/"; - use format; - use format-out; - use json; - use locators; - use operating-system, prefix: "os/"; + use deft-shared; + use workspaces; use pacman, prefix: "pm/", // Because / followed by * is seen as a comment by dylan-mode. rename: { *package-manager-directory* => *package-manager-directory* }; - use print; - use regular-expressions; - use shared; - use standard-io; - use streams; - use strings; - use threads; - use uncommon-dylan, - exclude: { format-out, format-to-string }; - use uncommon-utils, - import: { err, iff, inc!, slice }; - use workspaces; // Exports for the test suite. export @@ -212,29 +186,11 @@ define module %workspaces end module; define module deft - use collectors; - use command-line-parser; - use file-system, prefix: "fs/"; - use format; - use format-out; - use json; - use locators; - use operating-system, prefix: "os/"; + use deft-shared; use pacman, prefix: "pm/", - // Because / followed by * is seen as a comment by dylan-mode. + // Because pm/*... is seen as a /* comment by dylan-mode. rename: { *package-manager-directory* => *package-manager-directory* }; - use regular-expressions; - use shared; - use standard-io; - use streams; - use strings; - use threads, - import: { dynamic-bind }; - use uncommon-dylan, - exclude: { format-out, format-to-string }; - use uncommon-utils, - import: { err, iff, inc!, slice }; use workspaces, prefix: "ws/"; export diff --git a/sources/pacman/install-test.dylan b/sources/pacman/install-test.dylan index 995d8b6..58da4fa 100644 --- a/sources/pacman/install-test.dylan +++ b/sources/pacman/install-test.dylan @@ -12,19 +12,19 @@ define test test-install (tags: #["net"]) versions: #("1.0.0"), catalog: cat); let release = find-package-release(cat, "json", $latest); - let saved-dylan = environment-variable($dylan-env-var); + let saved-dylan = os/environment-variable($dylan-env-var); block () - environment-variable($dylan-env-var) := as(, dir); + os/environment-variable($dylan-env-var) := as(, dir); assert-false(installed?(release)); install(release); assert-true(installed?(release)); let lid-path = file-locator(dir, $package-directory-name, "json", "1.0.0", "src", "json.lid"); - assert-true(file-exists?(lid-path)); + assert-true(fs/file-exists?(lid-path)); let versions = installed-versions(release.package-name); assert-equal(1, size(versions)); assert-equal(map-as(, identity, versions), list(release.release-version)); cleanup - environment-variable($dylan-env-var) := saved-dylan; + os/environment-variable($dylan-env-var) := saved-dylan; end; end test; diff --git a/sources/shared.dylan b/sources/shared.dylan index d1a9f58..b8cf102 100644 --- a/sources/shared.dylan +++ b/sources/shared.dylan @@ -1,4 +1,4 @@ -Module: shared +Module: deft-shared // Whether to do verbose output. This is set based on the --verbose command diff --git a/sources/test-suite-library.dylan b/sources/test-suite-library.dylan index f74bed0..a88eff6 100644 --- a/sources/test-suite-library.dylan +++ b/sources/test-suite-library.dylan @@ -1,28 +1,17 @@ Module: dylan-user define library deft-test-suite - use common-dylan; - use deft; - use io; - use strings; - use system; use testworks; + + use deft; end library; define module deft-test-suite - use common-dylan; - use file-system; - use format; - use locators; - use operating-system; + use testworks; + + use deft-shared; // where we get the dylan module from use pacman; use %pacman; - use shared; - use standard-io; - use streams; - use strings; - use testworks; - use threads; use workspaces; use %workspaces; end module; diff --git a/sources/workspaces/workspaces-test.dylan b/sources/workspaces/workspaces-test.dylan index 726af67..0e10b24 100644 --- a/sources/workspaces/workspaces-test.dylan +++ b/sources/workspaces/workspaces-test.dylan @@ -7,7 +7,7 @@ define test test-find-workspace-directory () let ws = file-locator(tmp, $workspace-file-name); let dp = file-locator(tmp, "dp", $dylan-package-file-name); let bottom = subdirectory-locator(tmp, "dp", "abc", "xyz"); - ensure-directories-exist(bottom); + fs/ensure-directories-exist(bottom); // Initially there is no workspace directory. let ws-dir = find-workspace-directory(bottom);