difftreelog
Merge commit 'd93ca83fe3668f134c0a705b972e2b52072ebf3d'
in: master
3 files changed
.github/workflows/release.ymldiffbeforeafterboth53 needs: [test]53 needs: [test]54 strategy:54 strategy:55 matrix:55 matrix:56 os: [ubuntu-latest, macOS-latest, windows-latest]56 target:57 # Tier 158 - aarch64-unknown-linux-gnu59 - i686-pc-windows-gnu60 - i686-pc-windows-msvc61 - i686-unknown-linux-gnu62 - x86_64-apple-darwin63 - x86_64-pc-windows-gnu64 - x86_64-pc-windows-msvc65 - x86_64-unknown-linux-gnu6667 # Other68 - x86_64-unknown-linux-musl57 include:69 include:58 - os: ubuntu-latest70 - target: aarch64-unknown-linux-gnu59 rust: stable71 os: ubuntu-latest60 target: x86_64-unknown-linux-musl61 bin: jrsonnet72 bin: jrsonnet62 name: jrsonnet-linux-amd6473 name: jrsonnet-linux-gnu-aarch6463 - os: windows-latest74 - target: i686-pc-windows-gnu64 rust: stable75 os: windows-latest65 target: x86_64-pc-windows-msvc66 bin: jrsonnet.exe76 bin: jrsonnet.exe67 name: jrsonnet-windows-amd64.exe77 name: jrsonnet-windows-gnu-i686.exe78 - target: i686-pc-windows-msvc79 os: windows-latest80 bin: jrsonnet.exe81 name: jrsonnet-windows-msvc-i686.exe82 - target: i686-unknown-linux-gnu83 os: ubuntu-latest84 bin: jrsonnet85 name: jrsonnet-linux-gnu-i68668 - os: macOS-latest86 - target: x86_64-apple-darwin69 rust: stable87 os: macOS-latest70 target: x86_64-apple-darwin71 bin: jrsonnet88 bin: jrsonnet72 name: jrsonnet-darwin-amd6489 name: jrsonnet-darwin-amd6490 - target: x86_64-pc-windows-gnu91 os: windows-latest92 bin: jrsonnet.exe93 name: jrsonnet-windows-gnu-amd64.exe94 - target: x86_64-pc-windows-msvc95 os: windows-latest96 bin: jrsonnet.exe97 name: jrsonnet-windows-msvc-amd64.exe98 - target: x86_64-unknown-linux-gnu99 os: ubuntu-latest100 bin: jrsonnet101 name: jrsonnet-linux-gnu-amd64102103 - target: x86_64-unknown-linux-musl104 os: ubuntu-latest105 bin: jrsonnet106 name: jrsonnet-linux-musl-amd6473 runs-on: ${{ matrix.os }}107 runs-on: ${{ matrix.os }}74 steps:108 steps:75 - name: Install stable toolchain109 - name: Install stable toolchain76 uses: actions-rs/toolchain@v1110 uses: actions-rs/toolchain@v177 with:111 with:78 toolchain: ${{ matrix.rust }}112 toolchain: stable79 override: true113 override: true80 target: ${{ matrix.target }}114 target: ${{ matrix.target }}11581 - name: Checkout116 - name: Checkout82 uses: actions/checkout@v2117 uses: actions/checkout@v2118119 - name: Linux x86 cross compiler120 if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}121 run: sudo apt install gcc-multilib122123 - name: Windows x86 cross compiler124 if: ${{ matrix.target == 'i686-pc-windows-gnu' }}125 uses: egor-tensin/setup-mingw@v2126 with:127 platform: x86128129 - name: ARM cross compiler130 if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}131 uses: actions-rs/cargo@v1132 with:133 command: install134 args: cross135136 - name: Run ARM build137 if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}138 shell: bash139 run: cross --bin=jrsonnet --release --target ${{ matrix.target }}14083 - name: Run build141 - name: Run build142 if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}84 uses: actions-rs/cargo@v1143 uses: actions-rs/cargo@v185 with:144 with:86 command: build145 command: buildcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth1use crate::{1use crate::{2 equals,2 equals,3 error::{Error::*, Result},3 error::{Error::*, Result},4 parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, FuncVal, LazyVal,4 parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, EvaluationState,5 Val,5 FuncVal, LazyVal, Val,6};6};7use format::{format_arr, format_obj};7use format::{format_arr, format_obj};74 ("reverse".into(), builtin_reverse),74 ("reverse".into(), builtin_reverse),75 ("id".into(), builtin_id),75 ("id".into(), builtin_id),76 ("strReplace".into(), builtin_str_replace),76 ("strReplace".into(), builtin_str_replace),77 ("parseJson".into(), builtin_parse_json),77 ].iter().cloned().collect()78 ].iter().cloned().collect()78 };79 };79}80}164 })165 })165}166}167168fn builtin_parse_json(169 context: Context,170 _loc: Option<&ExprLocation>,171 args: &ArgsDesc,172) -> Result<Val> {173 parse_args!(context, "parseJson", args, 1, [174 0, s: ty!(string) => Val::Str;175 ], {176 let state = EvaluationState::default();177 let path = Rc::new(PathBuf::from("std.parseJson"));178 state.evaluate_snippet_raw(path ,s)179 })180}166181167// faster182// faster168fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {183fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth808 );808 );809 }809 }810811 #[test]812 fn parse_json() {813 assert_json!(814 r#"std.parseJson('{"a": -1,"b": 1,"c": 3.141,"d": []}')"#,815 r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#816 );817 // TODO: this should in fact fail as is no proper JSON syntax818 assert_json!(819 r#"std.parseJson("{a:-1, b:1, c:3.141, d:[]}")"#,820 r#"{"a": -1,"b": 1,"c": 3.141,"d": []}"#821 );822 // TODO: this is also no valid JSON823 assert_json!(r#"std.parseJson('local x = 2; x * x')"#, r#"4"#);824 }810825811 #[test]826 #[test]812 fn test() {827 fn test() {