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 read content from a .txt file #25

Open
jsortegac opened this issue Jun 6, 2017 · 1 comment
Open

How to read content from a .txt file #25

jsortegac opened this issue Jun 6, 2017 · 1 comment

Comments

@jsortegac
Copy link

Hi @hawk !

I'm new to Lux, but I have been "playing" with it for a while. Now I have a doubt about how to read some files (e.g. a .txt file) and "expect" some content. What I am doing at the moment is:

.lux file:

[doc prueba 4]

[global config4=$config4]
[global golden4=$golden4]

[shell uno]
    !echo ${config4}
    ?${golden4}

[cleanup]

And when I execute the lux command I do the following:
config4=$(cat config4.txt) golden4=$(cat golden4.txt) lux test4.lux

That way I am able to compare the content of that 2 files. But, is there a built in system to do that? or this is a "good" way?

Related to these question is another one. Am I able to use ?+ (undeterministic match) with the content loaded from a file?

Hope to hear you soon!

Thank you very much!
Jose

@ksallberg
Copy link

Hello,

I do not understand exactly how you want to compare those two files. Is your use case as simple as using the unix diff utility and checking that there are no diffs between files?

I do not know of any such built in functionality (binding files to variables) that you ask for.

Usually, you want your test to specify exactly what to expect in each step of your test. For example, making sure that some lines exist in a file. Loading two files and doing some comparison breaks this as the lux test result will vary depending on which files you compare.

Perhaps you want to write some bash/python script that you give your files to, and that outputs some results? Then the lux script could expect something in those results and the comparison logic will be lifted out of lux.

If you output a file so that lux will handle it, for instance by calling 'cat' or 'echo' from a lux script, then I see no reason as to why '?+' would not work. Did you find a case where it does not work?

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