define-runtime-path is designed for this problem, IIUC. Let me know if
the docs don't help.

Robby

On Thu, Jan 19, 2017 at 11:47 AM, David Storrs <[email protected]> wrote:
> Short form:  When using Dr Racket, how do I write something that says
> "Here is a path to a file that I care about.  The path is relative to
> you, the script that is running the code" ?
>
> Long form:
>
> I have a file, testing_utils.rkt, that includes the following snippet of code:
>
> (define (load-initial-data where)
>   (define cmd (string-append "psql -d biomantica < "
>                              (path->string
>                               (path-only
>                                (path->complete-path
>                                 (find-system-path 'run-file))))
>                              where))
>   (say "shelling out in order to load initial data into DB. Command
> is: \n\t" cmd)
>
>   (void
>    (with-output-to-string  ;; silence the output
>      (thunk
>       (system cmd)))))
>
>
> The way this gets used is that one of our test scripts (e.g.
> 'endpoints.t') will (require "path/to/testing_utils.rkt") and then
> call the load-initial-data function as follows:
>
> (load-initial-data "../initial_test_data.sql")
>
> I operate in Emacs via the shell, while my cofounder James uses Dr
> Racket.  The above sequence works for me but not for him.  When I run
> endpoints.t it locates the endpoints.t file, generates the path from
> there to the initial_test_data.sql file, and shells out to run that
> SQL through psql in order to load the database for testing.  When
> James tries it it fails.
>
> The failure seems to be that for me "the running script" is the
> endpoints.t file, while for him it's the Dr Racket executable.  I'm
> not sure where to even begin sorting this out, so I was hoping for
> some help.
>
> Any thoughts?
>
> Dave
>
>
> PS:  James had to step out for something else or he would be sending
> this himself.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to