Commit Graph

386 Commits

Author SHA1 Message Date
Luke Granger-Brown
643210d274 Add string output support for multifile output (#220)
* Add test support for multi-file output.

* Add -update support for multi-file output tests.

* Add support for string output in multi-file output mode.

* Rename 'stringOutput' to 'stringOutputMode' to better express what it does

* Refactor main_test to make it less nested.

This also causes the -update flag to output a list of files which
have been updated. This does not include the paths which are deleted
for multi-file tests.
2018-05-09 11:49:07 -04:00
Stanisław Barzowski
f4428e6d47 Better Importer interface
As discussed in https://github.com/google/go-jsonnet/issues/190
2018-04-28 01:34:42 -04:00
Roger Peppe
fde815f6a1 godoc.org-compatible ast package
Change the dump code so that it hides the values of variable
definitions if they're large. This means that godoc.org should
be able to deal with the output, and the godoc output is
readable without needing to read through a huge struct literal definition.

Other approaches might be to always generate an extra variable
(seems unnecessary) or to pass to writer explicitly to the dump
methods rather than swapping s.w out temporarily. The former
seems unnecessarily intrusive to the usual output; the latter
seemed unnecessarily intrusive to the source itself.
YMMV.
2018-04-12 14:06:52 -04:00
Dave Cunningham
dfddf2b4e3 Update version 2018-03-16 22:34:36 -04:00
Dave Cunningham
0b46b25f0f Update to cpp jsonnet 2018-03-16 22:20:53 -04:00
Dave Cunningham
6efde9677d Handle base case of cloneForSpec 2018-03-15 13:56:17 -04:00
Marcelo Cantos
b0459e4867 Add AppVeyor Windows builds and releases (#206)
* Make some filenames Windows-friendly

* Update references to renamed files

* Fix escaped filenames to run on non-Windows platforms
2018-03-12 20:46:57 -04:00
Marcelo Cantos
d67779ed8d Refactor handling of --{ext,tla}-* flags (#212)
* Refactor handling of --{ext,tla}-* flags

* better helper function names for --{ext,tla}-* flags
2018-03-11 16:44:59 -04:00
Dave Cunningham
405726fae2
Clone ASTs to avoid aliasing and double-unescaping (#210)
* Clone ASTs to avoid aliasing and double-unescaping
2018-03-07 11:23:32 -05:00
Dave Cunningham
5cc426ed04 Bring submodule and stdlib to cpp master 2018-03-06 23:49:02 -05:00
Marcelo Cantos
cf6933d45b Add C++-Jsonnet submodule for tests (#202)
* Add C++-Jsonnet submodule for tests
* Add tests.sh to travis-ci
2018-03-06 13:05:00 -05:00
Marcelo Cantos
88519c3704 Apply more golint recommendations (#201)
* Apply more golint recommendations

* Update dumpstdlibast.go to include StdAst comment

* Improve dump.go package comment.
2018-02-28 01:11:18 -05:00
Marcelo Cantos
ed5f280c59 Apply golint recommendations (#196)
* Apply golint recommendations
2018-02-26 14:12:25 -05:00
Marcelo Cantos
5ae4798d8d Clean up token strings 2018-02-25 13:41:11 -05:00
Stanisław Barzowski
44770e75dd Add std.sign and fix division by zero in stdlib 2018-02-21 20:31:04 -05:00
Petr Krebs
bed2cd89bc Do not assume that import path is always a filesystem path (do not clean it up) 2018-02-17 16:34:54 -05:00
Dave Cunningham
2ea01b24d8
Introduce a Parens AST (#189)
* Introduce a Parens AST
2018-02-16 13:01:14 -05:00
Dave Cunningham
f46dea2835 Update std.jsonnet 2018-02-01 14:21:39 -05:00
Stanisław Barzowski
61b33d1a2a Fast, native implementation of strReplace 2018-01-31 15:27:59 -05:00
Cam Hutchison
d1d9a7f5f8 Convert --tla/ext-*-file to imports
Instead of reading the files directly for --tla/ext-*-file, just add a
code snippet that does an import or importstr.

This makes relative imports work when the code-file path is not in the
current directory. It also makes the import lazy so if the arg/var is
not referenced, the file does not have to exist.

Fixes: google/jsonnet#452
2018-01-30 18:22:29 -05:00
Stanisław Barzowski
4406074d47 Add support for memory profiling 2018-01-27 18:44:54 -05:00
Stanisław Barzowski
eeecb7f100 Fix processing the same file many times
There was a trivial bug, which disabled caching
of parsed, desugared and analyzed code. So imports
were only cached on data level, not on executable
ast level.

This change will likely result in ~10x speedup
for some users.
2018-01-27 15:09:25 -05:00
Dave Cunningham
741f9f06a2 Update stdlib and ||| fix 2018-01-23 23:26:28 -05:00
Stanisław Barzowski
eedf6760ad Convert non-string errors to string 2018-01-18 12:48:38 -05:00
Stanisław Barzowski
d6623a98cb Oldest version known to work = Go 1.8, closes #177
It seems like it was broken on older compilers
since pregenerated stdlib AST.

It adds go 1.8.x to travis, so that we have a chance
of catching when our "known to work" no longer holds.
2018-01-18 12:48:20 -05:00
Stanisław Barzowski
d135effbe4 Add missing check for array out of bounds 2018-01-17 15:26:31 -05:00
Yewei Huang
561a986e8e Remove unnecessary type alias in jsonnet/cmd.go 2018-01-15 21:10:31 -05:00
Stanisław Barzowski
bc88189964 Very basic, experimental linter
No tests yet
2018-01-15 21:05:52 -05:00
Stanisław Barzowski
5fc25a6e75 Remove unnecessary type alias 2018-01-12 14:26:54 -05:00
Dave Cunningham
7d821fde83 std.join silently steps over null (match std.jsonnet version) 2018-01-11 09:37:26 -05:00
Stanisław Barzowski
34a24d8bcb Basic support for running jsonnet command in tests (#167)
A step towards a unified test suite. In particular this
lets us use C++ version with Go tests. The problem remains
that errors (both static and runtime) may differ between implementations.
This will require special handling. C++ version seems to pass all
"positive" tests. Go version also has this problem (error formatter used in tests is different).

Also native functions etc. are not handled in any way at the moment.
2018-01-10 21:27:44 -05:00
Dave Cunningham
7c8f4d0b12
Call top level function even if there are no TLAs (match cpp semantics) (#169)
* Call top level function even if there are no TLAs (match cpp semantics)
2018-01-10 20:43:55 -05:00
Cam Hutchison
c7a5b68f1c Add test case for native function returning error
A native function returning an error should be reported as a runtime
error, with a stack trace.
2017-12-18 10:22:53 -05:00
Stanisław Barzowski
de6b2b8a55 Make errors in native functions runtime errors
Instead of crashing with internal error
2017-12-18 10:22:21 -05:00
Stanisław Barzowski
c3551f4f61 Basic refactoring - towards shared e2e tests 2017-12-14 17:48:34 -05:00
Stanisław Barzowski
8ade994928 Efficient native implementation of std.join
It changes the behavior slightly - mixing strings
and arrays in join is no longer allowed.
2017-12-13 18:09:56 -05:00
Dave Cunningham
3481c9c698 Add JSONNET_PATH (go version) 2017-12-13 18:09:32 -05:00
Daniel Theophanes
83abda5985 jsonnet: fix docs, correct EvaluateSnippetMulti
EvaluateSnippetMulti comment was copied from another function by mistake.
Add a space between the license and the package name.
Add a few periods after the comments.

Fixes google/go-jsonnet#160
2017-12-13 18:09:05 -05:00
Daniel Theophanes
691e8d4f3c Remove unused dependencies
The imports in "_gen.go" were not used, compiled, or
apparently useful so remove.

The color field in the ErrorFormatter was never set
to true and never used. This brought in many unused
dependencies including x/sys/unix that aren't ever
used. Move the color dependencies to the jsonnet main
package and set the colorized output there. Turn the
exported ErrorFormatter into an interface. In the future
it could be used to export JSON or HTML output.

Fixes google/go-jsonnet#131
2017-12-12 00:05:28 -05:00
Stanisław Barzowski
f7eea3b545 Native implementation of std.range 2017-12-08 17:17:17 -05:00
Cam Hutchison
219d970ba0 jsonnet: Fix --output-file command line option
The long option --output-file was not working, due to what looks like a
cut and paste error, leaving --exec as the string to test for.
2017-12-08 15:34:11 -05:00
Dave Cunningham
fe6a54abaf Justify \/ escape 2017-12-07 21:05:26 -05:00
Dave Cunningham
dfc9428ac7 refactor import callback to separate error from return value 2017-11-24 20:32:46 -05:00
Dave Cunningham
c65317e03f Make fields of ImportedData public 2017-11-24 20:32:46 -05:00
Kuat Yessenov
ec5b07c45a Expose MemoryImporter data
Signed-off-by: Kuat Yessenov <kuat@google.com>
2017-11-15 22:38:13 -05:00
Liang Mingqiang
8f568c1115 remove escLocalFS (#150)
* remove escLocalFS

* update README
2017-11-10 09:55:22 -05:00
Liang Mingqiang
395102359b fix go vet error (#151) 2017-11-10 09:53:40 -05:00
Stanisław Barzowski
03e2a7f474 Fix bad format string (#149) 2017-11-09 08:56:06 -05:00
Liang Mingqiang
ce84685fb0 Sort FreeVariables slice (#148)
* sort FreeVariables slice

* regenerate the standard library AST
2017-11-09 08:55:36 -05:00
Dave Cunningham
b04e73e163 Fix unparsing of enums, avoid static type error 2017-11-08 11:28:38 -05:00