Thread overview
FYI: environment variables in Lit tests
Jan 23
kinke
January 17
Hi all,
  I just found out about lit's "env" command, see:
https://wiki.dlang.org/LDC_Lit-based_testsuite#Environment_variables

-Johan

January 23
On Thursday, 17 January 2019 at 00:42:23 UTC, Johan Engelen wrote:
> Hi all,
>   I just found out about lit's "env" command, see:
> https://wiki.dlang.org/LDC_Lit-based_testsuite#Environment_variables
>
> -Johan

FYI, env is a POSIX thing [1], so I think it works just by virtue of using the system shell. Unfortunately, I think you'll need to use a different thing for Windows, if the tests are not running in a msys2/mingw/cygwin environment.

[1]: https://www.unix.com/man-page/posix/1posix/env/
January 23
On Wednesday, 23 January 2019 at 11:13:06 UTC, Petar Kirov [ZombineDev] wrote:
> On Thursday, 17 January 2019 at 00:42:23 UTC, Johan Engelen wrote:
>> Hi all,
>>   I just found out about lit's "env" command, see:
>> https://wiki.dlang.org/LDC_Lit-based_testsuite#Environment_variables
>>
>> -Johan
>
> FYI, env is a POSIX thing [1], so I think it works just by virtue of using the system shell.

The cool thing is that Lit recognizes `env` and makes it work cross-platform (same as e.g. `rm` and `mkdir`).

-Johan


January 23
On Wednesday, 23 January 2019 at 12:06:21 UTC, Johan Engelen wrote:
> On Wednesday, 23 January 2019 at 11:13:06 UTC, Petar Kirov [ZombineDev] wrote:
>> On Thursday, 17 January 2019 at 00:42:23 UTC, Johan Engelen wrote:
>>> Hi all,
>>>   I just found out about lit's "env" command, see:
>>> https://wiki.dlang.org/LDC_Lit-based_testsuite#Environment_variables
>>>
>>> -Johan
>>
>> FYI, env is a POSIX thing [1], so I think it works just by virtue of using the system shell.
>
> The cool thing is that Lit recognizes `env` and makes it work cross-platform (same as e.g. `rm` and `mkdir`).
>
> -Johan

Yes, I think you're right. Previously I couldn't find information in the source code, but now I found this part of the documentation, which is pretty clear:

https://llvm.org/docs/TestingGuide.html#writing-new-regression-tests

> RUN lines are specified in the comments of the test program using the keyword RUN followed by a colon, and lastly the command (pipeline) to execute. Together, these lines form the “script” that lit executes to run the test case. The syntax of the RUN lines is similar to a shell’s syntax for pipelines including I/O redirection and variable substitution. **However, even though these lines may look like a shell script, they are not. RUN lines are interpreted by lit.** Consequently, the syntax differs from shell in a few ways. You can specify as many RUN lines as needed.

Do you know where I can find the relevant lines in the source code?
January 23
On Wednesday, 23 January 2019 at 16:53:26 UTC, Petar Kirov [ZombineDev] wrote:
> Do you know where I can find the relevant lines in the source code?

Not the lines, but the lit code is in https://github.com/llvm-mirror/llvm/tree/master/utils/lit/lit.

As a side note, when they made `cat` a builtin command, that broke some of our tests (IIRC because they forgot to ship that `builtin_commands/cat.py` for Windows or something like that).
January 23
On Wednesday, 23 January 2019 at 16:53:26 UTC, Petar Kirov [ZombineDev] wrote:
>
> Do you know where I can find the relevant lines in the source code?

See e.g.

https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/TestRunner.py#L823

and

https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/TestRunner.py#L745-L801

-Johan



January 24
On Wednesday, 23 January 2019 at 23:56:42 UTC, Johan Engelen wrote:
> On Wednesday, 23 January 2019 at 16:53:26 UTC, Petar Kirov [ZombineDev] wrote:
>>
>> Do you know where I can find the relevant lines in the source code?
>
> See e.g.
>
> https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/TestRunner.py#L823
>
> and
>
> https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/TestRunner.py#L745-L801
>
> -Johan

Thanks guys ;)