feat: add rust-script
This commit is contained in:
13
external/rust-script/tests/data/cargo-target-dir-env.rs
vendored
Normal file
13
external/rust-script/tests/data/cargo-target-dir-env.rs
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
use std::env;
|
||||
|
||||
pub fn main() {
|
||||
// Test that CARGO_TARGET_DIR is not set by rust-script to avoid
|
||||
// interfering with cargo calls done by the script.
|
||||
// See https://github.com/fornwall/rust-script/issues/27
|
||||
let env_variable = env::var("CARGO_TARGET_DIR");
|
||||
println!("--output--");
|
||||
println!(
|
||||
"{:?}",
|
||||
matches!(env_variable, Err(env::VarError::NotPresent))
|
||||
);
|
||||
}
|
||||
1
external/rust-script/tests/data/file-to-be-included.txt
vendored
Normal file
1
external/rust-script/tests/data/file-to-be-included.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
hello, including script
|
||||
10
external/rust-script/tests/data/outer-line-doc.rs
vendored
Normal file
10
external/rust-script/tests/data/outer-line-doc.rs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/// ```cargo
|
||||
/// [dependencies]
|
||||
/// boolinator = "=0.1.0"
|
||||
/// ```
|
||||
use boolinator::Boolinator;
|
||||
|
||||
pub fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
10
external/rust-script/tests/data/pub-fn-main.rs
vendored
Normal file
10
external/rust-script/tests/data/pub-fn-main.rs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
//! ```cargo
|
||||
//! [dependencies]
|
||||
//! boolinator = "=0.1.0"
|
||||
//! ```
|
||||
use boolinator::Boolinator;
|
||||
|
||||
pub fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
3
external/rust-script/tests/data/question-mark.rs
vendored
Normal file
3
external/rust-script/tests/data/question-mark.rs
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
use std::fs::File;
|
||||
|
||||
File::open("__rust-script-this-file-does-not-exist.txt")?;
|
||||
4
external/rust-script/tests/data/same-flags.rs
vendored
Normal file
4
external/rust-script/tests/data/same-flags.rs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
println!("--output--");
|
||||
if let Some(arg) = std::env::args().skip(1).next() {
|
||||
println!("Argument: {}", arg);
|
||||
}
|
||||
6
external/rust-script/tests/data/script-args.rs
vendored
Normal file
6
external/rust-script/tests/data/script-args.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
for (i, arg) in std::env::args().enumerate() {
|
||||
println!("{:>4}: {:?}", format!("[{}]", i), arg);
|
||||
}
|
||||
}
|
||||
14
external/rust-script/tests/data/script-async-main.rs
vendored
Normal file
14
external/rust-script/tests/data/script-async-main.rs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//! This is merged into a default manifest in order to form the full package manifest:
|
||||
//!
|
||||
//! ```cargo
|
||||
//! [dependencies]
|
||||
//! boolinator = "=0.1.0"
|
||||
//! tokio = { version = "1", features = ["full"] }
|
||||
//! ```
|
||||
use boolinator::Boolinator;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
12
external/rust-script/tests/data/script-cs-env.rs
vendored
Normal file
12
external/rust-script/tests/data/script-cs-env.rs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
let path = env::var("RUST_SCRIPT_PATH").expect("CSSP wasn't set");
|
||||
assert!(path.ends_with("script-cs-env.rs"));
|
||||
assert_eq!(env::var("RUST_SCRIPT_SAFE_NAME"), Ok("script-cs-env".into()));
|
||||
assert_eq!(env::var("RUST_SCRIPT_PKG_NAME"), Ok("script-cs-env".into()));
|
||||
let base_path = env::var("RUST_SCRIPT_BASE_PATH").expect("CSBP wasn't set");
|
||||
assert!(base_path.ends_with("data"));
|
||||
println!("Ok");
|
||||
}
|
||||
6
external/rust-script/tests/data/script-explicit.rs
vendored
Normal file
6
external/rust-script/tests/data/script-explicit.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
extern crate boolinator;
|
||||
use boolinator::Boolinator;
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
16
external/rust-script/tests/data/script-features.rs
vendored
Normal file
16
external/rust-script/tests/data/script-features.rs
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/*!
|
||||
```cargo
|
||||
[features]
|
||||
dont-panic = []
|
||||
```
|
||||
*/
|
||||
#[cfg(feature="dont-panic")]
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Keep calm and borrow check.");
|
||||
}
|
||||
|
||||
#[cfg(not(feature="dont-panic"))]
|
||||
fn main() {
|
||||
panic!("Do I really exist from an external, non-subjective point of view?");
|
||||
}
|
||||
11
external/rust-script/tests/data/script-full-block.rs
vendored
Normal file
11
external/rust-script/tests/data/script-full-block.rs
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//! This is merged into a default manifest in order to form the full package manifest:
|
||||
//!
|
||||
//! ```cargo
|
||||
//! [dependencies]
|
||||
//! boolinator = "=0.1.0"
|
||||
//! ```
|
||||
use boolinator::Boolinator;
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
11
external/rust-script/tests/data/script-full-line-without-main.rs
vendored
Normal file
11
external/rust-script/tests/data/script-full-line-without-main.rs
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env rust-script
|
||||
/// This is merged into a default manifest in order to form the full package manifest:
|
||||
///
|
||||
/// ```cargo
|
||||
/// [dependencies]
|
||||
/// boolinator = "=0.1.0"
|
||||
/// ```
|
||||
use boolinator::Boolinator;
|
||||
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
13
external/rust-script/tests/data/script-full-line.rs
vendored
Normal file
13
external/rust-script/tests/data/script-full-line.rs
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/*!
|
||||
This is merged into a default manifest in order to form the full package manifest:
|
||||
|
||||
```cargo
|
||||
[dependencies]
|
||||
boolinator = "=0.1.0"
|
||||
```
|
||||
*/
|
||||
use boolinator::Boolinator;
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
4
external/rust-script/tests/data/script-has.weird§chars!.rs
vendored
Normal file
4
external/rust-script/tests/data/script-has.weird§chars!.rs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Ok");
|
||||
}
|
||||
12
external/rust-script/tests/data/script-including-relative.rs
vendored
Normal file
12
external/rust-script/tests/data/script-including-relative.rs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
use std::env;
|
||||
|
||||
mod script_module {
|
||||
include!(concat!(env!("RUST_SCRIPT_BASE_PATH"), "/script-module.rs"));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
let s = include_str!(concat!(env!("RUST_SCRIPT_BASE_PATH"), "/file-to-be-included.txt"));
|
||||
assert_eq!(script_module::A_VALUE, 1);
|
||||
println!("{}", s);
|
||||
}
|
||||
12
external/rust-script/tests/data/script-invalid-doc-comment.rs
vendored
Normal file
12
external/rust-script/tests/data/script-invalid-doc-comment.rs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Hello, World!");
|
||||
}
|
||||
|
||||
/**
|
||||
```cargo
|
||||
[dependencies]
|
||||
i-cant-decide-whether-you-should = ["live", "die"]
|
||||
```
|
||||
*/
|
||||
fn dummy() {}
|
||||
1
external/rust-script/tests/data/script-module.rs
vendored
Normal file
1
external/rust-script/tests/data/script-module.rs
vendored
Normal file
@@ -0,0 +1 @@
|
||||
pub const A_VALUE: i32 = 1;
|
||||
4
external/rust-script/tests/data/script-no-deps.rs
vendored
Normal file
4
external/rust-script/tests/data/script-no-deps.rs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Hello, World!");
|
||||
}
|
||||
9
external/rust-script/tests/data/script-short-without-main.rs
vendored
Normal file
9
external/rust-script/tests/data/script-short-without-main.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// cargo-deps: boolinator="=0.1.0"
|
||||
// You can also leave off the version number, in which case, it's assumed
|
||||
// to be "*". Also, the `cargo-deps` comment *must* be a single-line
|
||||
// comment, and it *must* be the first thing in the file, after the
|
||||
// shebang.
|
||||
use boolinator::Boolinator;
|
||||
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
10
external/rust-script/tests/data/script-short.rs
vendored
Normal file
10
external/rust-script/tests/data/script-short.rs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// cargo-deps: boolinator="=0.1.0"
|
||||
// You can also leave off the version number, in which case, it's assumed
|
||||
// to be "*". Also, the `cargo-deps` comment *must* be a single-line
|
||||
// comment, and it *must* be the first thing in the file, after the
|
||||
// shebang.
|
||||
use boolinator::Boolinator;
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("{:?}", true.as_some(1));
|
||||
}
|
||||
10
external/rust-script/tests/data/script-slow-output.rs
vendored
Normal file
10
external/rust-script/tests/data/script-slow-output.rs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/*!
|
||||
```cargo
|
||||
[dependencies]
|
||||
slow-build = { version = "0.1.0", path = "slow-build" }
|
||||
```
|
||||
*/
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Ok");
|
||||
}
|
||||
2
external/rust-script/tests/data/script-test.rs
vendored
Normal file
2
external/rust-script/tests/data/script-test.rs
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#[test]
|
||||
fn test() {}
|
||||
6
external/rust-script/tests/data/script-unstable-feature.rs
vendored
Normal file
6
external/rust-script/tests/data/script-unstable-feature.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#![feature(lang_items)]
|
||||
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("`#![feature]` *may* be used!");
|
||||
}
|
||||
1
external/rust-script/tests/data/slow-build/.gitignore
vendored
Normal file
1
external/rust-script/tests/data/slow-build/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/Cargo.lock
|
||||
10
external/rust-script/tests/data/slow-build/Cargo.toml
vendored
Normal file
10
external/rust-script/tests/data/slow-build/Cargo.toml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "slow-build"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniel Keep <daniel.keep@gmail.com>"]
|
||||
|
||||
build = "slow-build-build.rs"
|
||||
|
||||
[lib]
|
||||
name = "slow_build"
|
||||
path = "slow-build-lib.rs"
|
||||
5
external/rust-script/tests/data/slow-build/slow-build-build.rs
vendored
Normal file
5
external/rust-script/tests/data/slow-build/slow-build-build.rs
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
println!("Sleeping for 2 seconds...");
|
||||
std::thread::sleep(std::time::Duration::from_millis(2000));
|
||||
println!("Done.");
|
||||
}
|
||||
0
external/rust-script/tests/data/slow-build/slow-build-lib.rs
vendored
Normal file
0
external/rust-script/tests/data/slow-build/slow-build-lib.rs
vendored
Normal file
9
external/rust-script/tests/data/templates/boolinate.rs
vendored
Normal file
9
external/rust-script/tests/data/templates/boolinate.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// cargo-deps: boolinator="0.1.0"
|
||||
#{prelude}
|
||||
|
||||
extern crate boolinator;
|
||||
use boolinator::Boolinator;
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", Boolinator::as_option({#{script}}));
|
||||
}
|
||||
9
external/rust-script/tests/data/templates/override/expr.rs
vendored
Normal file
9
external/rust-script/tests/data/templates/override/expr.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// cargo-deps: boolinator="0.1.0"
|
||||
#{prelude}
|
||||
|
||||
extern crate boolinator;
|
||||
use boolinator::Boolinator;
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", Boolinator::as_option({#{script}}));
|
||||
}
|
||||
11
external/rust-script/tests/data/templates/shout.rs
vendored
Normal file
11
external/rust-script/tests/data/templates/shout.rs
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#{prelude}
|
||||
|
||||
fn main() {
|
||||
match {#{script}} {
|
||||
script_result => {
|
||||
let text = script_result.to_string();
|
||||
let text = text.to_uppercase();
|
||||
println!("{}", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
external/rust-script/tests/data/time.rs
vendored
Normal file
6
external/rust-script/tests/data/time.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// cargo-deps: chrono
|
||||
extern crate chrono;
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("Hello");
|
||||
}
|
||||
4
external/rust-script/tests/data/whitespace-before-main.rs
vendored
Normal file
4
external/rust-script/tests/data/whitespace-before-main.rs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("--output--");
|
||||
println!("hello, world");
|
||||
}
|
||||
Reference in New Issue
Block a user