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

test: only run tests where exe is found #83

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,295 changes: 14 additions & 1,281 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ serde_json = "1.0.114"
tempfile = "3.10.1"

[dev-dependencies]
test-with = "0.12.6"
test-with = { version = "0.12.6", default-features = false, features = [
"executable"
] }
1 change: 1 addition & 0 deletions src/formatters/autopep8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_autopep8 {

use super::format_using_autopep8;

#[test_with::executable(autopep8)]
#[test]
fn it_should_format_python() {
let input = "def add( a: int , b:int)->int: return a+b";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/black.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_black {

use super::format_using_black;

#[test_with::executable(black)]
#[test]
fn it_should_format_python() {
let input = "def add( a: int , b:int)->int: return a+b";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/blue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_blue {

use super::format_using_blue;

#[test_with::executable(blue)]
#[test]
fn it_should_format_python() {
let input = "def add( a: int , b:int)->int: return a+b";
Expand Down
8 changes: 8 additions & 0 deletions src/formatters/clang_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod test_clang_format {
languages::Language,
};

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_c() {
let input = "int add(int a,int b){
Expand All @@ -41,6 +42,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_cpp() {
let input = "int add(int a,int b){
Expand All @@ -64,6 +66,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_csharp() {
let input = "namespace Mdsf {
Expand All @@ -89,6 +92,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_javascript() {
let input = " async function asyncAddition( a,b) {
Expand All @@ -109,6 +113,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_json() {
let input = " {
Expand All @@ -130,6 +135,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_objective_c() {
let input = "int add(int a,int b){
Expand All @@ -153,6 +159,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_protobuf() {
let input = "service SearchService {
Expand All @@ -173,6 +180,7 @@ mod test_clang_format {
assert_eq!(expected_output, output);
}

#[test_with::executable(clang-format)]
#[test]
fn it_should_format_java() {
let input = "class HelloWorld {
Expand Down
1 change: 1 addition & 0 deletions src/formatters/crystal_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_crystal_format {

use super::format_using_crystal_format;

#[test_with::executable(crystal)]
#[test]
fn it_should_format_crystal() {
let input = "def add(a, b) return a + b end";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/dart_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn format_using_dart_format(
mod test_dart_format {
use crate::{formatters::setup_snippet, languages::Language};

#[test_with::executable(dart)]
#[test]
fn it_should_format_dart() {
let input = "class Adder { int add(int a, int b) { return a + b; } } ";
Expand Down
3 changes: 3 additions & 0 deletions src/formatters/deno_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_deno_fmt {

use super::format_using_deno_fmt;

#[test_with::executable(deno)]
#[test]
fn it_should_format_json() {
let input = "
Expand Down Expand Up @@ -54,6 +55,7 @@ mod test_deno_fmt {
assert_eq!(expected_output, output);
}

#[test_with::executable(deno)]
#[test]
fn it_should_format_javascript() {
let input = "
Expand All @@ -79,6 +81,7 @@ mod test_deno_fmt {
assert_eq!(expected_output, output);
}

#[test_with::executable(deno)]
#[test]
fn it_should_format_typescript() {
let input = "
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/elm_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ mod test_elm_format {

main =
text "Hello!"


"#;
let expected_output = r#"module Main exposing (main)

Expand Down
1 change: 1 addition & 0 deletions src/formatters/gleam_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod test_gleam_format {
languages::Language,
};

#[test_with::executable(gleam)]
#[test]
fn it_should_format_gleam() {
let input = "pub fn add(a:Int,b:Int)->Int{a+b}";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/gofmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod test_gofmt {
languages::Language,
};

#[test_with::executable(gofmt)]
#[test]
fn it_should_format_go() {
let input = "package main
Expand Down
1 change: 1 addition & 0 deletions src/formatters/gofumpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn format_using_gofumpt(
mod test_gofumpt {
use crate::{formatters::setup_snippet, languages::Language};

#[test_with::executable(gofumpt)]
#[test]
fn it_should_format_go() {
let input = "package main
Expand Down
1 change: 1 addition & 0 deletions src/formatters/isort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_isort {

use super::format_using_isort;

#[test_with::executable(isort)]
#[test]
fn it_should_format_python() {
let input = "from q import d
Expand Down
1 change: 1 addition & 0 deletions src/formatters/just_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod test_just_fmt {
languages::Language,
};

#[test_with::executable(just)]
#[test]
fn it_should_format_just() {
let input = "build:
Expand Down
1 change: 1 addition & 0 deletions src/formatters/mix_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod test_mix_format {
languages::Language,
};

#[test_with::executable(mix)]
#[test]
fn it_should_format_elixir() {
let input = "
Expand Down
1 change: 1 addition & 0 deletions src/formatters/nimpretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod test_nimpretty {
languages::Language,
};

#[test_with::executable(nimpretty)]
#[test]
fn it_should_format_nim() {
let input = "proc add( a :int , b:int ) : int =
Expand Down
3 changes: 1 addition & 2 deletions src/formatters/ocamlformat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ mod test_ocamlformat {
languages::Language,
};

/// NOTE: this is ignored since the ocaml runtime takes a long time to installed
#[test_with::no_env(GITHUB_ACTIONS)]
#[test_with::executable(ocamlformat)]
#[test]
fn it_should_format_ocaml() {
let input = "
Expand Down
1 change: 1 addition & 0 deletions src/formatters/roc_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_roc_format {

use super::format_using_roc_format;

#[test_with::executable(roc)]
#[test]
fn it_should_format_roc() {
let input = r#"app "helloWorld"
Expand Down
1 change: 1 addition & 0 deletions src/formatters/rubocop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod test_rubocop {
languages::Language,
};

#[test_with::executable(rubocop)]
#[test]
fn it_should_format_ruby() {
let input = "def add( a , b )
Expand Down
1 change: 1 addition & 0 deletions src/formatters/ruff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod test_ruff {

use super::format_using_ruff;

#[test_with::executable(ruff)]
#[test]
fn it_should_format_python() {
let input = "def add( a: int , b:int)->int: return a+b";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/rustfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod test_rustfmt {

use super::format_using_rustfmt;

#[test_with::executable(rustfmt)]
#[test]
fn it_should_format_rust() {
let input = "pub
Expand Down
2 changes: 2 additions & 0 deletions src/formatters/shfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod test_shfmt {
languages::Language,
};

#[test_with::executable(shfmt)]
#[test]
fn it_should_format_sh() {
let input = "
Expand Down Expand Up @@ -52,6 +53,7 @@ add() {
assert_eq!(expected_output, output);
}

#[test_with::executable(shfmt)]
#[test]
fn it_should_format_bash() {
let input = "
Expand Down
1 change: 1 addition & 0 deletions src/formatters/sqlfluff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn format_using_sqlfluff(
mod test_sqlfluff {
use crate::{formatters::setup_snippet, languages::Language};

#[test_with::executable(sqlfluff)]
#[test]
fn it_should_format_sql() {
let input = "SELECT * FROM tbl
Expand Down
1 change: 1 addition & 0 deletions src/formatters/usort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_isort {

use super::format_using_usort;

#[test_with::executable(usort)]
#[test]
fn it_should_format_python() {
let input = "from q import d
Expand Down
1 change: 1 addition & 0 deletions src/formatters/yapf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod test_yapf {

use super::format_using_yapf;

#[test_with::executable(yapf)]
#[test]
fn it_should_format_python() {
let input = "def add( a: int , b:int)->int: return a+b";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/zigfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod test_zigfmt {
languages::Language,
};

#[test_with::executable(zig)]
#[test]
fn it_should_format_zig() {
let input = "
Expand Down
1 change: 1 addition & 0 deletions src/languages/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod test_c {
.is_none());
}

#[test_with::executable(clang-format)]
#[test]
fn test_clang_format() {
let l = Lang::<C> {
Expand Down
1 change: 1 addition & 0 deletions src/languages/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod test_cpp {
.is_none());
}

#[test_with::executable(clang-format)]
#[test]
fn test_clang_format() {
let l = Lang::<Cpp> {
Expand Down
1 change: 1 addition & 0 deletions src/languages/crystal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod test_crystal {
.is_none());
}

#[test_with::executable(crystal)]
#[test]
fn test_crystal_format() {
let expected_output = "def add(a, b)
Expand Down
1 change: 1 addition & 0 deletions src/languages/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod test_csharp {
.is_none());
}

#[test_with::executable(clang-format)]
#[test]
fn test_clang_format() {
let l = Lang::<CSharp> {
Expand Down
1 change: 1 addition & 0 deletions src/languages/dart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod test_dart {
.is_none());
}

#[test_with::executable(dart)]
#[test]
fn test_dart_format() {
let l = Lang::<Dart> {
Expand Down
1 change: 1 addition & 0 deletions src/languages/elixir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod test_elixir {
.is_none());
}

#[test_with::executable(mix)]
#[test]
fn test_mix_format() {
let l = Lang::<Elixir> {
Expand Down
4 changes: 2 additions & 2 deletions src/languages/elm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ mod test_elm {

main =
text "Hello!"


"#;

const EXTENSION: &str = crate::languages::Language::Elm.to_file_ext();
Expand Down
1 change: 1 addition & 0 deletions src/languages/gleam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod test_gleam {
.is_none());
}

#[test_with::executable(gleam)]
#[test]
fn test_gleam_format() {
let l = Lang::<Gleam> {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ mod test_go {
.is_none());
}

#[test_with::executable(gofmt)]
#[test]
fn test_gofmt() {
let l = Lang::<Go> {
Expand All @@ -110,6 +111,7 @@ func add(a int, b int) int {
assert_eq!(output, expected_output);
}

#[test_with::executable(gofumpt)]
#[test]
fn test_gofumpt() {
let l = Lang::<Go> {
Expand Down
1 change: 1 addition & 0 deletions src/languages/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mod test_java {
.is_none());
}

#[test_with::executable(clang-format)]
#[test]
fn test_clang_format() {
let expected_output = "class HelloWorld {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ mod test_javascript {
assert_eq!(output, expected_output);
}

#[test_with::executable(clang-format)]
#[test]
fn test_clang_format() {
let input = " async function asyncAddition( a,b) {
Expand All @@ -181,6 +182,7 @@ mod test_javascript {
assert_eq!(expected_output, output);
}

#[test_with::executable(deno)]
#[test]
fn test_deno_fmt() {
let input = " async function asyncAddition( a,b) {
Expand Down
Loading
Loading