Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locator-directory should not return empty string #1470

Closed
cgay opened this issue Jan 15, 2023 · 0 comments
Closed

locator-directory should not return empty string #1470

cgay opened this issue Jan 15, 2023 · 0 comments

Comments

@cgay
Copy link
Member

cgay commented Jan 15, 2023

I think it should be valid to do ensure-directory-exists(relative-path). While fixing dylan-lang/testworks#157 I wrote this test:

// 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;

test-temp-directory makes a relative path because I've set DYLAN that way, and then calls ensure-directories-exist with it, which ends up with the following error because locator-directory returns the empty string.

$ $DW/testworks/_build/bin/testworks-test-suite-app --test test-test-temp-directory/absolute-path --debug crashes
Running test test-test-temp-directory/absolute-path:test-directory = dylan/root/_test/cgay-20230115-181036/test-test-temp-directory_absolute-path/
creating directory {<posix-directory-locator> ""}  // I added this debug output to ensure-directories-exist
No such file or directory: Can't create the directory
Backtrace:
  0x7fc7014acd98
  default-handler:dylan:dylan##1 + 0x12
  0x79643a6e616c7964
  default-last-handler:common-dylan-internals:common-dylan##0 + 0x2f6
  error:dylan:dylan##0 + 0x27
  unix-file-error:system-internals:system + 0x227
  %create-directory:system-internals:system + 0x94
  KdoitF193I + 0x9e
  KdoitF193I + 0x71
  KdoitF193I + 0x71
  KdoitF193I + 0x71
  KdoitF193I + 0x71
  ensure-directories-exist:file-system:system##0 + 0x71
  test-temp-directory:testworks:testworks + 0x1b4
  %%test-test-temp-directory/absolute-path:testworks-test-suite:testworks-test-suite + 0x34
  Kanonymous_of_execute_componentF71I + 0x360
  do-with-profiling:common-dylan-internals:common-dylan + 0x2f
  execute-component:%testworks:testworks##1 + 0x244
  maybe-execute-component:%testworks:testworks##0 + 0x113
  run-tests:testworks:testworks + 0x88
  run-or-list-tests:%testworks:testworks + 0xaa
  run-test-application:testworks:testworks + 0x413
  main + 0x19
cgay added a commit to cgay/opendylan that referenced this issue Jan 15, 2023
It doesn't make sense for a relative directory locator to have an empty
directory path. (But it does make sense for an absolute directory locator, in
which case it represents the root directory.)

Fixes dylan-lang#1470
cgay added a commit to cgay/opendylan that referenced this issue Jan 15, 2023
It doesn't make sense for a relative directory locator to have an empty
directory path. (But it does make sense for an absolute directory locator, in
which case it represents the root directory.)

Fixes dylan-lang#1470
cgay added a commit to cgay/opendylan that referenced this issue Jan 15, 2023
It doesn't make sense for a relative directory locator to have an empty
directory path. (But it does make sense for an absolute directory locator, in
which case it represents the root directory.)

Fixes dylan-lang#1470
@cgay cgay closed this as completed in e157783 Jan 16, 2023
cgay added a commit to cgay/opendylan that referenced this issue Mar 29, 2023
It doesn't make sense for a relative directory locator to have an empty
directory path. (But it does make sense for an absolute directory locator, in
which case it represents the root directory.)

Fixes dylan-lang#1470
cgay added a commit to cgay/opendylan that referenced this issue Apr 8, 2024
It doesn't make sense for a relative directory locator to have an empty
directory path. (But it does make sense for an absolute directory locator, in
which case it represents the root directory.)

Fixes dylan-lang#1470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant