Skip to content

Commit

Permalink
chore: invert integration tests
Browse files Browse the repository at this point in the history
This moves from a single integration tests `all` to one test
module per .rs file with a
common module for the ecma262 and major_libs
  • Loading branch information
FreeMasen committed Nov 24, 2022
1 parent 8fa3fae commit ca165c0
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 36 deletions.
File renamed without changes.
10 changes: 5 additions & 5 deletions tests/all/ecma262.rs → tests/ecma262.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#![cfg(test)]
use super::{get_js_file, EverythingVersion, Lib};
mod libs_common;
use env_logger;
use libs_common::{get_js_file, EverythingVersion, Lib};

use ressa::Parser;
#[test]
fn es5() {
let _ = env_logger::builder().is_test(true).try_init().ok();
info!("ES5");
log::info!("ES5");
let path = Lib::Everything(EverythingVersion::Es5).path();
log::debug!("path: {:?}", path);
let js = get_js_file(&path).unwrap_or_else(|e| panic!("Faield to get {:?}\n{}", path, e));
Expand All @@ -18,7 +18,7 @@ fn es5() {
#[test]
fn es2015_script() {
let _ = env_logger::builder().is_test(true).try_init().ok();
info!("ES2015 Script");
log::info!("ES2015 Script");
let path = Lib::Everything(EverythingVersion::Es2015Script).path();
let js = get_js_file(&path).expect(&format!("Failed to get {:?}", path));
let mut p = Parser::new(&js).expect("Failed to create parser");
Expand All @@ -28,7 +28,7 @@ fn es2015_script() {

#[test]
fn es2015_module() {
info!("ES2015 Module");
log::info!("ES2015 Module");
let _ = env_logger::builder().is_test(true).try_init().ok();
let path = Lib::Everything(EverythingVersion::Es2015Module).path();
let js = get_js_file(&path).expect(&format!("Failed to get {:?}", path));
Expand Down
18 changes: 3 additions & 15 deletions tests/all/main.rs → tests/libs_common.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate ress;
extern crate ressa;

mod comment_handler;
mod ecma262;
mod major_libs;
mod snippets;
#[cfg(feature = "moz_central")]
mod spider_monkey;

#![allow(unused)]
use std::{fs::read_to_string, io::Error};

#[derive(Clone, Copy, Debug)]
enum Lib {
pub enum Lib {
Jquery,
Angular,
React,
Expand All @@ -25,7 +13,7 @@ enum Lib {
Everything(EverythingVersion),
}
#[derive(Clone, Copy, Debug)]
enum EverythingVersion {
pub enum EverythingVersion {
Es5,
Es2015Module,
Es2015Script,
Expand Down
8 changes: 5 additions & 3 deletions tests/all/major_libs.rs → tests/major_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
use env_logger;
use ressa::Parser;

use super::{get_js_file, Lib};
mod libs_common;

use libs_common::Lib;

#[test]
fn angular1() {
Expand Down Expand Up @@ -84,12 +86,12 @@ fn get_js(l: Lib) -> Result<(String, String), ::std::io::Error> {
}

fn get_normal_js(l: Lib) -> Result<String, ::std::io::Error> {
get_js_file(l.path())
libs_common::get_js_file(l.path())
}

fn get_min_js(l: Lib) -> Result<String, ::std::io::Error> {
if let Some(p) = l.min_path() {
get_js_file(&p)
libs_common::get_js_file(&p)
} else {
Err(::std::io::Error::new(
::std::io::ErrorKind::NotFound,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: res
---
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: tokens
---
Mod(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: tokens
---
Script(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tests/all/ecma262.rs
source: tests/ecma262.rs
expression: tokens
---
Script(
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion tests/all/spider_monkey.rs → tests/spider_monkey.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(test)]
#![cfg(feature = "moz_central")]

use ressa::{Builder, Error};
use std::path::Path;
use walkdir::WalkDir;
Expand Down

0 comments on commit ca165c0

Please sign in to comment.