refactor: create fixtures module
Prepare for adding a second radically different fixture by creating a module to hold the different fixtures. When I only had one fixture it was ok to have the module be a single file.
This commit is contained in:
parent
401aec67d0
commit
6790eec12c
5 changed files with 5 additions and 14 deletions
1
src/exec/fixtures/mod.rs
Normal file
1
src/exec/fixtures/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod scripting;
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::elm;
|
use crate::elm;
|
||||||
use crate::fixture;
|
|
||||||
use crate::reporting::{CompilerError, InterpreterError, Problem, SetupError, TypeError};
|
use crate::reporting::{CompilerError, InterpreterError, Problem, SetupError, TypeError};
|
||||||
use crate::PortableHash;
|
use crate::PortableHash;
|
||||||
use deno_core::futures::StreamExt;
|
use deno_core::futures::StreamExt;
|
||||||
|
|
@ -19,6 +18,8 @@ use std::time::Instant;
|
||||||
use tokio;
|
use tokio;
|
||||||
use tracing::{info_span, Instrument};
|
use tracing::{info_span, Instrument};
|
||||||
|
|
||||||
|
mod fixtures;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(tag = "$")]
|
#[serde(tag = "$")]
|
||||||
pub(crate) enum ElmResult<T, E> {
|
pub(crate) enum ElmResult<T, E> {
|
||||||
|
|
@ -104,7 +105,7 @@ pub(crate) fn exec(
|
||||||
// step 7 create an Elm fixture file to run our function
|
// step 7 create an Elm fixture file to run our function
|
||||||
let span = info_span!("create Elm fixture files");
|
let span = info_span!("create Elm fixture files");
|
||||||
let timing_guard = span.enter();
|
let timing_guard = span.enter();
|
||||||
let (gen_module_name, source) = fixture::generate(
|
let (gen_module_name, source) = fixtures::scripting::generate(
|
||||||
source_checksum,
|
source_checksum,
|
||||||
entrypoint.0.module.clone(),
|
entrypoint.0.module.clone(),
|
||||||
entrypoint.1.clone(),
|
entrypoint.1.clone(),
|
||||||
|
|
@ -194,7 +195,7 @@ pub(crate) fn exec(
|
||||||
final_script = final_script
|
final_script = final_script
|
||||||
.replace(
|
.replace(
|
||||||
"var $author$project$Astrid$Query$execute = function (query) {\n\treturn $author$project$Astrid$Query$dummyExecute;\n};",
|
"var $author$project$Astrid$Query$execute = function (query) {\n\treturn $author$project$Astrid$Query$dummyExecute;\n};",
|
||||||
include_str!("../fixture/query.js"),
|
include_str!("fixtures/sql-client-integration.js"),
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"var $author$project$Astrid$Query$fetch = F3(\n\tfunction (sql, parameters, decoder) {\n\t\treturn $author$project$Astrid$Query$Dummy;\n\t});",
|
"var $author$project$Astrid$Query$fetch = F3(\n\tfunction (sql, parameters, decoder) {\n\t\treturn $author$project$Astrid$Query$Dummy;\n\t});",
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -1,7 +1,6 @@
|
||||||
extern crate naive_wadler_prettier as pretty;
|
extern crate naive_wadler_prettier as pretty;
|
||||||
use crate::timings::Timings;
|
use crate::timings::Timings;
|
||||||
use pretty::pretty;
|
use pretty::pretty;
|
||||||
use sqlx::Row;
|
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
@ -11,7 +10,6 @@ use tracing::info_span;
|
||||||
|
|
||||||
mod elm;
|
mod elm;
|
||||||
mod exec;
|
mod exec;
|
||||||
mod fixture;
|
|
||||||
mod reporting;
|
mod reporting;
|
||||||
mod timings;
|
mod timings;
|
||||||
mod transpile;
|
mod transpile;
|
||||||
|
|
@ -23,7 +21,6 @@ fn main() {
|
||||||
tracing::subscriber::set_global_default(span_subscriber).unwrap();
|
tracing::subscriber::set_global_default(span_subscriber).unwrap();
|
||||||
|
|
||||||
match args {
|
match args {
|
||||||
// Arguments::Make { file, debug, output } => {
|
|
||||||
Arguments::Exec {
|
Arguments::Exec {
|
||||||
file,
|
file,
|
||||||
debug,
|
debug,
|
||||||
|
|
@ -108,14 +105,6 @@ impl ::core::hash::Hasher for PortableHash {
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
enum Arguments {
|
enum Arguments {
|
||||||
//Make {
|
|
||||||
// #[structopt(parse(from_os_str))]
|
|
||||||
// file: PathBuf,
|
|
||||||
// #[structopt(long)]
|
|
||||||
// debug: bool,
|
|
||||||
// #[structopt(long)]
|
|
||||||
// output: Option<PathBuf>,
|
|
||||||
//},
|
|
||||||
Exec {
|
Exec {
|
||||||
#[structopt(parse(from_os_str))]
|
#[structopt(parse(from_os_str))]
|
||||||
file: PathBuf,
|
file: PathBuf,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue