Skip to content

Commit

Permalink
chore: progress
Browse files Browse the repository at this point in the history
  • Loading branch information
clechasseur committed Oct 21, 2023
1 parent c792d5e commit 836c6e3
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "rust-template-output"
version = "0.1.0"
edition = "2021"
default-run = "rust-template-output"

[features]
test_feature_1 = []
Expand Down
11 changes: 5 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::env;

// use rustc_version::version_meta;
// use rustc_version::Channel::Nightly;
use rustc_version::version_meta;
use rustc_version::Channel::Nightly;

fn main() {
println!("cargo:rerun-if-env-changed=CI");

// Uncomment this to be notified when we're building on Nightly toolset
// if version_meta().unwrap().channel <= Nightly {
// println!("cargo:rustc-cfg=nightly_rustc");
// }
if version_meta().unwrap().channel <= Nightly {
println!("cargo:rustc-cfg=nightly_rustc");
}

// On CI, do not run integration tests.
if env::var("CI").is_ok() {
Expand Down
14 changes: 14 additions & 0 deletions src/bin/bin_1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use rust_template_output::hello;

fn main() {
println!("{} (from bin_1)", hello());
}

#[cfg(test)]
mod tests {
#[test]
fn test_bin_1_one() {
let foo = "foo";
assert!(!foo.is_empty());
}
}
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// Returns hello string
///
/// ```
/// use rust_template_output::hello;
///
/// let foo = hello();
/// assert!(!foo.is_empty());
/// ```
pub fn hello() -> &'static str {
"Hello, World!"
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_lib_one() {
let foo = hello();
assert!(!foo.is_empty());
}
}
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
use rust_template_output::hello;

fn main() {
println!("Hello, world!");
println!("{}", hello());

if cfg!(feature = "test_feature_1") {
println!("test-feature-1 is enabled");
} else {
println!("test-feature-1 is disabled");
}
}

#[cfg(test)]
mod tests {
#[test]
fn test_main_one() {
let foo = "foo";
assert!(!foo.is_empty());
}
}
2 changes: 1 addition & 1 deletion tarpaulin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
workspace = true
all-features = true
engine = "Llvm"
exclude-files = [ "target*/*" ]
exclude-files = [ "target*/*", "src/main.rs", "src/bin/*" ]
run-types = [ "Tests" ]
out = [ "Html", "Xml" ]
7 changes: 7 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use rust_template_output::hello;

#[test]
fn test_integration_one() {
let foo = hello();
assert!(!foo.is_empty());
}

0 comments on commit 836c6e3

Please sign in to comment.