diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 0b2db6446642..000000000000 --- a/.gitmodules +++ /dev/null @@ -1,14 +0,0 @@ -[submodule "xtask/coverage/test262"] - path = xtask/coverage/test262 - url = https://github.com/tc39/test262.git - shallow = true - -[submodule "xtask/coverage/Typescript"] - path = xtask/coverage/Typescript - url = https://github.com/microsoft/Typescript - shallow = true - -[submodule "xtask/coverage/babel"] - path = xtask/coverage/babel - url = https://github.com/babel/babel - shallow = true diff --git a/xtask/coverage/.gitignore b/xtask/coverage/.gitignore new file mode 100644 index 000000000000..013bd9bbba4b --- /dev/null +++ b/xtask/coverage/.gitignore @@ -0,0 +1,3 @@ +babel/ +test262/ +Typescript/ diff --git a/xtask/coverage/Typescript b/xtask/coverage/Typescript deleted file mode 160000 index 61a96b1641ab..000000000000 --- a/xtask/coverage/Typescript +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 61a96b1641abe24c4adc3633eb936df89eb991f2 diff --git a/xtask/coverage/babel b/xtask/coverage/babel deleted file mode 160000 index 33a6be4e56b1..000000000000 --- a/xtask/coverage/babel +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 33a6be4e56b149647c15fd6c0157c1413456851d diff --git a/xtask/coverage/src/js/test262.rs b/xtask/coverage/src/js/test262.rs index 9240196fde6d..7ed8593e8286 100644 --- a/xtask/coverage/src/js/test262.rs +++ b/xtask/coverage/src/js/test262.rs @@ -9,6 +9,8 @@ use regex::Regex; use serde::Deserialize; use std::io; use std::path::Path; +use std::process::Command; +use xtask::project_root; const BASE_PATH: &str = "xtask/coverage/test262/test"; @@ -160,6 +162,25 @@ impl TestSuite for Test262TestSuite { BASE_PATH } + fn checkout(&self) -> io::Result<()> { + let base_path = project_root().join(BASE_PATH); + let mut command = Command::new("git"); + command + .arg("clone") + .arg("https://github.com/tc39/test262.git") + .arg("--depth") + .arg("1") + .arg(base_path.display().to_string()); + command.output()?; + let mut command = Command::new("git"); + command + .arg("reset") + .arg("--hard") + .arg("715dd1073bc060f4ee221e2e74770f5728e7b8a0"); + command.output()?; + Ok(()) + } + fn is_test(&self, path: &Path) -> bool { match path.extension() { None => false, diff --git a/xtask/coverage/src/jsx/jsx_babel.rs b/xtask/coverage/src/jsx/jsx_babel.rs index 26ddb788f57b..5d78e313abc7 100644 --- a/xtask/coverage/src/jsx/jsx_babel.rs +++ b/xtask/coverage/src/jsx/jsx_babel.rs @@ -6,7 +6,10 @@ use crate::{ use biome_js_parser::{parse, JsParserOptions}; use biome_js_syntax::{JsFileSource, ModuleKind}; use biome_rowan::SyntaxKind; +use std::io; use std::path::Path; +use std::process::Command; +use xtask::project_root; const OK_PATH: &str = "xtask/coverage/babel/packages/babel-parser/test/fixtures/jsx/basic"; @@ -88,4 +91,21 @@ impl TestSuite for BabelJsxTestSuite { let code = check_file_encoding(path)?; Some(Box::new(BabelJsxTestCase::new(path, code))) } + fn checkout(&self) -> io::Result<()> { + let base_path = project_root().join("xtask/coverage/babel"); + let mut command = Command::new("git"); + command + .arg("clone") + .arg("https://github.com/babel/babel.git") + .arg(base_path.display().to_string()); + command.output()?; + let mut command = Command::new("git"); + command + .arg("reset") + .arg("--hard") + .arg("33a6be4e56b149647c15fd6c0157c1413456851d"); + command.output()?; + + Ok(()) + } } diff --git a/xtask/coverage/src/runner.rs b/xtask/coverage/src/runner.rs index a659314e3559..79305fa4de8f 100644 --- a/xtask/coverage/src/runner.rs +++ b/xtask/coverage/src/runner.rs @@ -9,6 +9,7 @@ use biome_js_parser::{parse, JsParserOptions, Parse}; use biome_js_syntax::{AnyJsRoot, JsFileSource, JsSyntaxNode}; use biome_rowan::SyntaxKind; use std::fmt::Debug; +use std::io; use std::panic::RefUnwindSafe; use std::path::Path; use walkdir::WalkDir; @@ -183,6 +184,7 @@ pub(crate) trait TestSuite: Send + Sync { fn base_path(&self) -> &str; fn is_test(&self, path: &Path) -> bool; fn load_test(&self, path: &Path) -> Option>; + fn checkout(&self) -> io::Result<()>; } pub(crate) struct TestSuiteInstance { @@ -221,6 +223,7 @@ pub(crate) fn run_test_suite( test_suite: &dyn TestSuite, context: &mut TestRunContext, ) -> TestResults { + test_suite.checkout().expect("To checkout the repository"); context.reporter.test_suite_started(test_suite); let instance = load_tests(test_suite, context); context.reporter.test_suite_run_started(&instance); diff --git a/xtask/coverage/src/symbols/msts.rs b/xtask/coverage/src/symbols/msts.rs index 72352189e512..2e3248b1aaa1 100644 --- a/xtask/coverage/src/symbols/msts.rs +++ b/xtask/coverage/src/symbols/msts.rs @@ -8,8 +8,11 @@ use crate::runner::{TestCase, TestCaseFiles, TestRunOutcome, TestSuite}; use biome_js_parser::JsParserOptions; use std::collections::HashSet; use std::fmt::Write; +use std::io; use std::path::{Path, PathBuf}; +use std::process::Command; use std::str::FromStr; +use xtask::project_root; const CASES_PATH: &str = "xtask/coverage/Typescript/tests/baselines/reference"; const BASE_PATH: &str = "xtask/coverage/Typescript"; @@ -193,6 +196,26 @@ impl TestSuite for SymbolsMicrosoftTestSuite { } } + fn checkout(&self) -> io::Result<()> { + let base_path = project_root().join(BASE_PATH); + let mut command = Command::new("git"); + command + .arg("clone") + .arg("https://github.com/microsoft/Typescript.git") + .arg("--depth") + .arg("1") + .arg(base_path.display().to_string()); + command.output()?; + let mut command = Command::new("git"); + command + .arg("reset") + .arg("--hard") + .arg("61a96b1641abe24c4adc3633eb936df89eb991f2"); + command.output()?; + + Ok(()) + } + fn load_test(&self, path: &Path) -> Option> { Some(Box::new(SymbolsMicrosoftTestCase::new(path))) } diff --git a/xtask/coverage/src/ts/ts_babel.rs b/xtask/coverage/src/ts/ts_babel.rs index 1099f2a28eed..001c0f19d38d 100644 --- a/xtask/coverage/src/ts/ts_babel.rs +++ b/xtask/coverage/src/ts/ts_babel.rs @@ -6,7 +6,10 @@ use crate::{ use biome_js_parser::JsParserOptions; use biome_js_syntax::{JsFileSource, LanguageVariant}; use biome_rowan::SyntaxKind; +use std::io; use std::path::Path; +use std::process::Command; +use xtask::project_root; const CASES_PATH: &str = "xtask/coverage/babel/packages/babel-parser/test/fixtures/typescript"; @@ -89,6 +92,26 @@ impl TestSuite for BabelTypescriptTestSuite { CASES_PATH } + fn checkout(&self) -> io::Result<()> { + let base_path = project_root().join("xtask/coverage/babel"); + let mut command = Command::new("git"); + command + .arg("clone") + .arg("https://github.com/babel/babel.git") + .arg("--depth") + .arg("1") + .arg(base_path.display().to_string()); + command.output()?; + let mut command = Command::new("git"); + command + .arg("reset") + .arg("--hard") + .arg("33a6be4e56b149647c15fd6c0157c1413456851d"); + command.output()?; + + Ok(()) + } + fn is_test(&self, path: &std::path::Path) -> bool { path.extension().map_or(false, |x| x == "ts") } diff --git a/xtask/coverage/src/ts/ts_microsoft.rs b/xtask/coverage/src/ts/ts_microsoft.rs index 18f87f2fe734..4a0af034eb8d 100644 --- a/xtask/coverage/src/ts/ts_microsoft.rs +++ b/xtask/coverage/src/ts/ts_microsoft.rs @@ -8,7 +8,10 @@ use biome_rowan::{AstNode, SyntaxKind}; use regex::Regex; use std::convert::TryFrom; use std::fmt::Write; +use std::io; use std::path::Path; +use std::process::Command; +use xtask::project_root; const CASES_PATH: &str = "xtask/coverage/Typescript/tests/cases"; const REFERENCE_PATH: &str = "xtask/coverage/Typescript/tests/baselines/reference"; @@ -95,6 +98,25 @@ impl TestSuite for MicrosoftTypescriptTestSuite { let code = check_file_encoding(path)?; Some(Box::new(MicrosoftTypeScriptTestCase::new(path, code))) } + + fn checkout(&self) -> io::Result<()> { + let base_path = project_root().join("xtask/coverage/Typescript"); + let mut command = Command::new("git"); + command + .arg("clone") + .arg("https://github.com/microsoft/Typescript.git") + .arg("--depth") + .arg("1") + .arg(base_path.display().to_string()); + command.output()?; + let mut command = Command::new("git"); + command + .arg("reset") + .arg("--hard") + .arg("61a96b1641abe24c4adc3633eb936df89eb991f2"); + command.output()?; + Ok(()) + } } struct TestCaseMetadata { diff --git a/xtask/coverage/test262 b/xtask/coverage/test262 deleted file mode 160000 index 715dd1073bc0..000000000000 --- a/xtask/coverage/test262 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 715dd1073bc060f4ee221e2e74770f5728e7b8a0