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

Add support for calling loadPackage for "User" package #3418

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

d-torrance
Copy link
Member

Previously, we got an error because User.m2 doesn't exist.

The use case I was interested in is creating and running tests outside of a package:

i1 : TEST "assert(1 + 1 == 2)"

i2 : tests User

o2 = HashTable{0 => TestInput[stdio:1:1-2:1]}

o2 : HashTable

i3 : code 0

o3 =  -- stdio:2:1: location of test code
     assert(1 + 1 == 2)

So far, so good! But now:

i4 : check User
 -- capturing check(0, "User")                  -- 0.057196 seconds elapsed
stdio:4:5:(3): error: file not found on path: "User.m2"

The problem is due to loadPackage, which always tries to load a file. If we just immediately return the User package when loadPackage "User" is called, then everything works:

i2 : check User
 -- capturing check(0, "User")                   -- 0.0576815 seconds elapsed

i3 : 

@d-torrance d-torrance requested a review from mahrud August 20, 2024 13:47
@mahrud mahrud linked an issue Aug 20, 2024 that may be closed by this pull request
@mahrud
Copy link
Member

mahrud commented Aug 20, 2024

Unrelated, but can we have tests return a numbered vertical list?

i2 : tests User

o2 = HashTable{0 => TestInput[stdio:1:1-2:1]}

o2 : HashTable

i3 : code 0

@mahrud
Copy link
Member

mahrud commented Aug 20, 2024

Side note: it's a little alarming that User.PackageIsLoaded is false.

@d-torrance
Copy link
Member Author

PackageIsLoaded is usually set by endPackage, but that never gets called for User. And it probably shouldn't -- but calling endPackage "User" doesn't raise any errors.

@d-torrance d-torrance requested a review from mahrud August 21, 2024 01:15
@mahrud
Copy link
Member

mahrud commented Aug 21, 2024

I don't see why someone would call endPackage on User, but I also don't see why it should be an error (for the same reasons as loadPackage).

I should say that if you set PackageIsLoaded to true then your change in loadPackage is actually unnecessary to get check working.

Usually set by endPackage, but that isn't called for User
@d-torrance
Copy link
Member Author

Good points!

I've changed this so that it's just the PackageIsLoaded commit. check "User" and needsPackage "User" now work nicely. loadPackage "User" still raises the "file not found" error, but I think that kind of makes sense since we can't really "load" it.

@mahrud
Copy link
Member

mahrud commented Aug 21, 2024

Oh yes, that makes sense!

@mahrud mahrud merged commit 41e49bd into Macaulay2:development Aug 21, 2024
5 checks passed
@d-torrance d-torrance deleted the load-user branch September 3, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check User doesn't work
2 participants