Skip to content

Commit 0378849

Browse files
authored
👷 Completely reworked integration tests (#16)
Integration tests are now modualarized, and you can create new tests very easily. Stdout and stderr comparisons are supported. This is done using example projects that lightmon actually will compile and run inside, allowing us to test as an actual binary program.
1 parent 8423d98 commit 0378849

File tree

122 files changed

+684
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+684
-66
lines changed

Cargo.lock

Lines changed: 108 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ exclude = [
1414
"assets/*"
1515
]
1616

17-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18-
1917
[dependencies]
2018
notify = "4.0.12"
2119
clap = {version = "~2.27.0", features = ["yaml"]}
22-
assert_cmd = "1.0.3"
23-
predicates = "1"
2420
walkdir = "2"
2521
log = "0.4.0"
2622
env_logger = "0.8.3"
2723
termcolor = "1.1.2"
2824
serde_json = "1.0"
25+
26+
[dev-dependencies]
27+
assert_cmd = "1.0.3"
28+
serial_test = "0.5.1"

src/cli.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl Cli {
8080
/// If there is a `package.json` in the root directory, lightmon attempts to resolve the exec command
8181
/// in the following order:
8282
/// 1. The value at `scripts.start`
83-
/// 2. The value at `scripts.run`
84-
/// 3. `node main` where `main` is the value of the `main` key in `package.json` (the entry point of the project).
83+
/// 2. `node main` where `main` is the value of the `main` key in `package.json` (the entry point of the project).
8584
///
8685
/// **NOTE:** exec command will fallback to `node index.js` if all of the above fail.
8786
///
@@ -108,10 +107,10 @@ impl Cli {
108107
pub fn build_node_config() -> Self {
109108
debug!("Configuring for node mode...");
110109
let watch_patterns: Vec<String> = vec![
111-
".jsx".to_string(),
112-
".js".to_string(),
113-
".html".to_string(),
114-
".css".to_string(),
110+
"*.jsx".to_string(),
111+
"*.js".to_string(),
112+
"*.html".to_string(),
113+
"*.css".to_string(),
115114
];
116115
let mut exec_commands: Vec<String> = Vec::new();
117116

@@ -128,13 +127,7 @@ impl Cli {
128127
"scripts.start found! Resolving exec_commands as '{}'",
129128
scripts_start
130129
);
131-
exec_commands.push(scripts_start.to_string());
132-
} else if let Some(scripts_run) = scripts.get("run") {
133-
debug!(
134-
"scripts.run found! Resolvig exec_commands as '{}'",
135-
scripts_run
136-
);
137-
exec_commands.push(scripts_run.to_string());
130+
exec_commands.push(scripts_start.as_str().unwrap().to_string());
138131
}
139132
}
140133

@@ -145,7 +138,8 @@ impl Cli {
145138
"main found! Resolving exec_commands as '{}'",
146139
main_entry_point
147140
);
148-
exec_commands.push(format!("node {}", main_entry_point))
141+
// main_entry_point has a " on either end, so we need to trim
142+
exec_commands.push(format!("node {}", main_entry_point.as_str().unwrap()));
149143
}
150144
}
151145
}
@@ -164,14 +158,22 @@ impl Cli {
164158
}
165159
}
166160

161+
/// Build the `rust` configuration.
162+
///
163+
/// ### Watch Patterns
164+
/// [`Cargo.toml`, `.rs`]
165+
///
166+
/// ### Exec Commands
167+
/// `cargo run`
167168
pub fn build_rust_config() -> Self {
168169
debug!("Configuring for rust mode...");
169170
Cli {
170171
watch_patterns: vec!["*.rs".to_string(), "Cargo.toml".to_string()],
171172
project_language: SupportedLanguage::Rust,
172-
exec_commands: vec!["cargo build".to_string(), "cargo run".to_string()],
173+
exec_commands: vec!["cargo run".to_string()],
173174
}
174175
}
176+
175177
pub fn build_shell_config(sub_matcher: &ArgMatches) -> Self {
176178
let mut watch_patterns: Vec<String> = Vec::new();
177179
let mut exec_commands: Vec<String> = Vec::new();

tests/cli.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("called by fallback")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("called by main entry point\n")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "node_basic",
3+
"version": "1.0.0",
4+
"description": "",
5+
"author": "",
6+
"license": "ISC"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("called by script.start\n")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("called by fallback");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("called by main entry point")

0 commit comments

Comments
 (0)