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

How to check if Inline configuration or code compilation succeeded without risking die? #81

Open
hadjiprocopis opened this issue Jun 14, 2024 · 3 comments

Comments

@hadjiprocopis
Copy link

hadjiprocopis commented Jun 14, 2024

I am adding a new Inline language (CUDA, heavily based on Inline::C) and in testing it it occured to me that I am not able to test whether configuration (i.e. use Inline C => Config => list)) or compilation (i.e. use Inline C => code) was successful.

The only way I can think of is to enclose Inline->bind() in a try/catch-or-eval block.

But it does not seem bind() is called at all. I read the caveats under bind() but could not understand them.

use Inline;
use Try::Tiny;
try {
  Inline->bind(C => code, config);
} catch { die "failed: $_" }

although this seems to call bind():

use Inline;
Inline->bind(C => code, config);

but I risk diying unexpectedly ...

Of course I can create a temp testfile with the Inline code/config on the fly and run it from my main test file to see if it compiles. But that's cumbersome...

10 min edit: Also see: https://perlmonks.org/?node_id=11159977 and the suggestion for require+import which works too

20 min edit: actually bind() is called inside try/catch and eval. Perhaps I had stale files in _Inline dir

@mohawk2
Copy link
Collaborator

mohawk2 commented Jun 20, 2024

Is this in fact now resolved?

@hadjiprocopis
Copy link
Author

hadjiprocopis commented Jun 20, 2024

it is not an issue. I was kind of asking a question really. So unless you know the answer, there is no point to keep this open (If you were asking me whether it can be closed).

@mohawk2
Copy link
Collaborator

mohawk2 commented Jun 20, 2024

I believe the correct answer is "use bind in an eval or try".

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

No branches or pull requests

2 participants