Skip to content

Commit

Permalink
Return absolute path from test-temp-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cgay committed Sep 26, 2023
1 parent d3b3658 commit 06379ff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions run.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define function test-temp-directory () => (d :: false-or(<directory-locator>))
full-component-name(*component*));
let test-directory
= subdirectory-locator(base, "_test", uniquifier, safe-name);
test-output("test-directory = %s\n", test-directory);
fs/ensure-directories-exist(test-directory);
test-directory
end
Expand Down
9 changes: 4 additions & 5 deletions tests/library.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define library testworks-test-suite
import: { format, streams };
use strings;
use system,
import: { file-system, locators };
import: { file-system, locators, operating-system };
use testworks;

export testworks-test-suite;
Expand All @@ -24,14 +24,13 @@ end library testworks-test-suite;
define module testworks-test-suite
use command-line-parser;
use common-dylan;
use file-system,
prefix: "fs/";
use file-system, prefix: "fs/";
use format;
use locators;
use operating-system, prefix: "os/";
use streams;
use strings;
use table-extensions,
import: { tabling };
use table-extensions, import: { tabling };
use testworks;
use %testworks;

Expand Down
17 changes: 17 additions & 0 deletions tests/run.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ define test test-test-temp-directory/slash-replaced? ()
locator-name(dir));
end;

// https://github.com/dylan-lang/testworks/issues/157
define test test-test-temp-directory/absolute-path ()
let dylan = os/environment-variable("DYLAN");
block ()
// This value must be a relative path.
// This test is obviously not thread safe.
os/environment-variable("DYLAN") := "dylan/root";
let tmp = test-temp-directory();
let d1 = subdirectory-locator(tmp, "d1");
let f1 = merge-locators(as(<file-locator>, "f1"), tmp);
let f2 = write-test-file(f1, content: "x");
assert-equal(resolve-locator(f1), resolve-locator(f2));
cleanup
os/environment-variable("DYLAN") := dylan;
end;
end test;

define test test-write-test-file ()
let x = write-test-file("x");
assert-instance?(<file-locator>, x);
Expand Down
2 changes: 2 additions & 0 deletions tests/suite.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ define suite testworks-test-suite ()
test test-run-tests/suite;
test test-run-tests/test;
test test-tags-match?;
test test-test-temp-directory/absolute-path;
test test-test-temp-directory/slash-replaced?;
test test-test-temp-directory;
test test-that-not-implemented-is-not-a-failure;
test test-that-not-implemented-plus-passed-is-passed;
Expand Down

0 comments on commit 06379ff

Please sign in to comment.