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

Client tests don't work with changes in Mojo 24.3 #34

Open
saviorand opened this issue May 6, 2024 · 5 comments
Open

Client tests don't work with changes in Mojo 24.3 #34

saviorand opened this issue May 6, 2024 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@saviorand
Copy link
Owner

Since Mojo 24.3 main() functions inside packages are no longer supported.

This was used in /tests/run.mojo to run a test suite (which is just one client test for now).
The client test worked by running a server in another process (terminal tab) via mojo lightbug.🔥, then running mojo tests/run.mojo.

Now I tried to work around the issue, and moved the test suite to lightbug.🔥, which is where the main function for the whole package lives.
I'm using the ability to pass a key-value to mojo run command like so: mojo -D "TEST" lightbug.🔥.

Currently this doesn't work, getting a bunch of compile errors. I'm assuming this has more to do with the Mojo client code than with the new way to run the main() function, but if anyone has ideas would appreciate.

@saviorand saviorand added the help wanted Extra attention is needed label May 6, 2024
@saviorand
Copy link
Owner Author

Here is the full error that throws when trying to run mojo -D "TEST" lightbug.🔥 on the latest branch. I'm on an M1 Mac.

/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:136:4: error: function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:136:4: note:   call expansion failed - no concrete specializations
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:91:4: note:     function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:107:18: note:       call expansion failed - no concrete specializations
/lightbug.🔥:4:4: note:         function instantiation failed
fn main() raises:
   ^
/lightbug.🔥:7:22: note:           call expansion failed - no concrete specializations
            run_tests()
                     ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
/lightbug_http/tests/run.mojo:10:4: note:             function instantiation failed
fn run_tests() raises:
   ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
/lightbug_http/tests/run.mojo:11:21: note:               call expansion failed - no concrete specializations
    run_client_tests()
                    ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
/lightbug_http/tests/run.mojo:14:4: note:                 function instantiation failed
fn run_client_tests() raises:
   ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
/lightbug_http/tests/run.mojo:19:32: note:                   call expansion failed - no concrete specializations
    test_python_client_lightbug(py_client)
                               ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
Included from /lightbug_http/tests/run.mojo:3:
/lightbug_http/tests/test_client.mojo:42:4: note:                     function instantiation failed
fn test_python_client_lightbug(client: PythonClient) raises:
   ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
Included from /lightbug_http/tests/run.mojo:3:
/lightbug_http/tests/test_client.mojo:43:24: note:                       call expansion failed - no concrete specializations
    var res = client.do(
                       ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
Included from /lightbug_http/tests/run.mojo:1:
/lightbug_http/python/client.mojo:30:8: note:                         function instantiation failed
    fn do(self, req: HTTPRequest) raises -> HTTPResponse:
       ^
Included from /lightbug_http/__init__.mojo:1:
Included from /lightbug_http/__init__.mojo:4:
Included from /lightbug_http/tests/run.mojo:1:
/lightbug_http/python/client.mojo:50:33: note:                           call expansion failed - no concrete specializations
        _ = self.socket.connect((UnsafeString(host_str.__str__()), port))
                                ^
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/python/object.mojo:253:8: note:                             function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/python/object.mojo:293:29: note:                               call expansion failed - no concrete specializations
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/utils/loop.mojo:30:4: note:                                 function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/utils/loop.mojo:41:33: note:                                   call expansion failed - no concrete specializations
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/utils/loop.mojo:60:4: note:                                     function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/utils/loop.mojo:67:18: note:                                       call expansion failed - no concrete specializations
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/python/object.mojo:267:12: note:                                         function instantiation failed
/Users/ec2-user/actions-runner/_work/modular/modular/Kernels/mojo/stdlib/builtin/constrained.mojo:34:6: note:                                           constraint failed: cannot convert nested list element to object
mojo: error: failed to run the pass manager

@thatstoasty
Copy link
Contributor

I updated

_ = self.socket.connect((UnsafeString(host_str.__str__()), port))
to
_ = self.socket.connect(host_str, port)

launched the lightbug server in a separate terminal, then ran the tests and it got past the compilation errors. But it did fail with what seems to be a string termination issue. And also maybe using the wrong service (content length doesn't match)

Connected to server at localhost:8080
Test suite failed: At /Users/mikhailtavarez/Git/mojo/lightbug_http/lightbug_http/tests/test_client.mojo:22:25: AssertionError: `left == right` comparison failed:
   left: HTTP/1.1 200 OK
Server: lightbug_http
Content-Type: text/html
Content-Length: 355872
Connection: close
Dat
  right: HTTP/1.1 200 OK
Server: lightbug_http
Content-Type: text/plain
Content-Length: 12
Connection: close
Date: 

@saviorand
Copy link
Owner Author

Oops, @thatstoasty I think as a server need to run bench.mojo for this client test. I tried that with your fix but getting
Test suite failed: socket.connect() takes exactly one argument (0 given)
I think it doesn't like tuples now, maybe related to this: modularml/mojo@430ff03

@thatstoasty
Copy link
Contributor

Interesting, are you passing host and port as two separate args or a tuple?

@saviorand
Copy link
Owner Author

This is if I copy from your previous message, two args, like this:
_ = self.socket.connect(host_str, port)
If I wrap it in a tuple like
_ = self.socket.connect((host_str, port))
Getting the long output like in my first comment, with constraint failed: cannot convert nested list element to object.
Tried different ways to do it: with and without UnsafeString, calling str(), wrapping in String, assigning tuple to a variable before passing, didn't seem to help 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: In progress
Development

No branches or pull requests

2 participants