From 164eba340410e7b827c6788f66af919c57089d7f Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Wed, 16 Dec 2020 18:54:59 +0100 Subject: [PATCH] Rename backend_js to backend_node --- Cargo.toml | 4 ++-- src/generator/mod.rs | 2 +- src/tests/mod.rs | 18 ++++++++++++++++++ src/tests/test_examples.rs | 19 +++++++++++-------- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d65444a..68406ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ edition = "2018" [features] backend_c = [] -backend_js = [] +backend_node = [] -default = ["backend_js"] +default = ["backend_node"] [dependencies] structopt = "0.3.21" diff --git a/src/generator/mod.rs b/src/generator/mod.rs index 137834a..2e96df1 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -31,7 +31,7 @@ pub fn generate(prog: Program) -> String { c::CGenerator::generate(prog) } - #[cfg(feature = "backend_js")] + #[cfg(feature = "backend_node")] { js::JsGenerator::generate(prog) } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 064566d..8d00b6a 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1 +1,19 @@ +/** + * Copyright 2020 Garrit Franke + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// This test currently only runs on the node backend, and has to be disabled for the C backend +#[cfg(backend_node)] mod test_examples; diff --git a/src/tests/test_examples.rs b/src/tests/test_examples.rs index 56f2fae..ee974dc 100644 --- a/src/tests/test_examples.rs +++ b/src/tests/test_examples.rs @@ -45,14 +45,17 @@ fn test_examples() -> Result<(), Error> { .success(); assert_eq!(success, true, "{:?}", &in_file); - let node_installed = Command::new("node").arg("-v").spawn()?.wait()?.success(); - if node_installed { - let execution = Command::new("node") - .arg(out_file) - .spawn()? - .wait()? - .success(); - assert_eq!(execution, true, "{:?}", &in_file) + #[cfg(backend_node)] + { + let node_installed = Command::new("node").arg("-v").spawn()?.wait()?.success(); + if node_installed { + let execution = Command::new("node") + .arg(out_file) + .spawn()? + .wait()? + .success(); + assert_eq!(execution, true, "{:?}", &in_file) + } } } Ok(())