test hjson parsing, and output (in JSON format)
* test nu-json output matches serde-json output * reinstate previous hjson tests that were asserting that nu-json outputs in hjson format which it does not * add dev dependencies: [fancy-regex, serde_json] to nu-json
This commit is contained in:
parent
82732a404d
commit
35ca051288
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -3193,7 +3193,10 @@ dependencies = [
|
|||
name = "nu-json"
|
||||
version = "0.95.1"
|
||||
dependencies = [
|
||||
"fancy-regex",
|
||||
"linked-hash-map",
|
||||
"nu-path",
|
||||
"nu-test-support",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
[package]
|
||||
authors = ["The Nushell Project Developers", "Christian Zangl <laktak@cdak.net>"]
|
||||
authors = [
|
||||
"The Nushell Project Developers",
|
||||
"Christian Zangl <laktak@cdak.net>",
|
||||
]
|
||||
description = "Fork of serde-hjson"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-json"
|
||||
edition = "2021"
|
||||
|
@ -19,9 +22,11 @@ default = ["preserve_order"]
|
|||
[dependencies]
|
||||
linked-hash-map = { version = "0.5", optional = true }
|
||||
num-traits = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
# nu-path = { path="../nu-path", version = "0.95.1" }
|
||||
# serde_json = "1.0"
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.95.1" }
|
||||
nu-path = { path = "../nu-path", version = "0.95.1" }
|
||||
serde_json = "1.0"
|
||||
fancy-regex = "0.13.0"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// FIXME: re-enable tests
|
||||
/*
|
||||
use nu_json::Value;
|
||||
use fancy_regex::Regex;
|
||||
use nu_json::Value;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -21,15 +19,7 @@ fn txt(text: &str) -> String {
|
|||
}
|
||||
|
||||
fn hjson_expectations() -> PathBuf {
|
||||
let assets = nu_test_support::fs::assets().join("nu_json");
|
||||
|
||||
nu_path::canonicalize(assets.clone()).unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Couldn't canonicalize hjson assets path {}: {:?}",
|
||||
assets.display(),
|
||||
e
|
||||
)
|
||||
})
|
||||
nu_test_support::fs::assets().join("nu_json")
|
||||
}
|
||||
|
||||
fn get_test_content(name: &str) -> io::Result<String> {
|
||||
|
@ -73,7 +63,8 @@ macro_rules! run_test {
|
|||
let actual_hjson = txt(&actual_hjson);
|
||||
let actual_json = $fix(serde_json::to_string_pretty(&udata).unwrap());
|
||||
let actual_json = txt(&actual_json);
|
||||
if rhjson != actual_hjson {
|
||||
// nu_json::to_string now outputs json instead of hjson!
|
||||
if rjson != actual_hjson {
|
||||
println!(
|
||||
"{:?}\n---hjson expected\n{}\n---hjson actual\n{}\n---\n",
|
||||
name, rhjson, actual_hjson
|
||||
|
@ -85,7 +76,7 @@ macro_rules! run_test {
|
|||
name, rjson, actual_json
|
||||
);
|
||||
}
|
||||
assert!(rhjson == actual_hjson && rjson == actual_json);
|
||||
assert!(rjson == actual_hjson && rjson == actual_json);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
@ -208,5 +199,3 @@ fn test_hjson() {
|
|||
panic!();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user