Skip to content

Commit

Permalink
move output tests to their own project
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Mar 2, 2025
1 parent 65e464b commit f6e0247
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 25 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"compiler-core",
"compiler-wasm",
"test-helpers-rs",
"test-output",
"test-package-compiler",
"test-project-compiler",
]
Expand Down
2 changes: 1 addition & 1 deletion compiler-cli/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn get_distro_str() -> String {
}

/// A `FileWriter` implementation that writes to the file system.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct ProjectIO {
beam_compiler: Arc<Mutex<crate::beam_compiler::BeamCompiler>>,
}
Expand Down
6 changes: 2 additions & 4 deletions compiler-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ mod docs;
mod export;
mod fix;
mod format;
mod fs;
pub mod fs;
mod hex;
mod http;
mod lsp;
mod new;
mod panic;
mod publish;
mod remove;
mod run;
pub mod run;
mod shell;
#[cfg(test)]
mod tests;

use config::root_config;
use dependencies::UseManifest;
Expand Down
2 changes: 1 addition & 1 deletion compiler-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn command(
std::process::exit(status);
}

pub(crate) fn setup(
pub fn setup(
paths: &ProjectPaths,
arguments: Vec<String>,
target: Option<Target>,
Expand Down
15 changes: 15 additions & 0 deletions test-output/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "test-output"
version = "1.8.1"
authors = ["Louis Pilfold <[email protected]>"]
edition = "2024"
license = "Apache-2.0"

[dependencies]
gleam-core = { path = "../compiler-core" }
gleam-cli = { path = "../compiler-cli" }
test-helpers-rs = { path = "../test-helpers-rs" }
camino = { workspace = true, features = ["serde1"] }

[dev-dependencies]
insta.workspace = true
2 changes: 2 additions & 0 deletions test-output/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[cfg(test)]
mod tests;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gleam_core::{
paths::ProjectPaths,
};

use crate::{
use gleam_cli::{
fs,
run::{self, Which},
};
Expand All @@ -17,9 +17,8 @@ fn run_and_produce_pretty_snapshot(
runtime: Option<Runtime>,
project_directory: Utf8PathBuf,
) -> String {
let paths = fs::get_project_root(project_directory)
.map(ProjectPaths::new)
.expect("project paths");
let project_root = fs::get_project_root(project_directory).expect("project root");
let paths = ProjectPaths::new(project_root);

let output = run_and_capture_output(&paths, "main", target, runtime)
// Echo's output includes paths, so we need this to make sure tests do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: compiler-cli/src/tests/echo.rs
source: test-output/src/tests/echo.rs
expression: output
---
--- main.gleam ----------------------
Expand Down

0 comments on commit f6e0247

Please sign in to comment.