summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/workflow.yml17
-rw-r--r--src/modules/haskell.rs31
-rw-r--r--src/utils.rs4
-rw-r--r--tests/testsuite/haskell.rs71
-rw-r--r--tests/testsuite/main.rs1
5 files changed, 31 insertions, 93 deletions
diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml
index ac281d0b1..124c8eeaf 100644
--- a/.github/workflows/workflow.yml
+++ b/.github/workflows/workflow.yml
@@ -116,23 +116,6 @@ jobs:
toolchain: stable
override: true
- # Install Stack at a fixed version (Linux & macOS version)
- - name: Install Stack [-nix]
- if: matrix.os != 'windows-latest'
- uses: mstksg/setup-stack@v1
-
- # Install Stack at a fixed version (Windows version), use Chocolatey
- - name: Install Stack [-windows]
- if: matrix.os == 'windows-latest'
- uses: crazy-max/ghaction-chocolatey@v1
- with:
- args: install haskell-stack -y
-
- - name: Install GHC version
- env:
- ARGS: --resolver nightly-2019-09-21
- run: stack $ARGS ghc -- --numeric-version --no-install-ghc
-
# Install Golang at a fixed version
- uses: actions/setup-go@v1
with:
diff --git a/src/modules/haskell.rs b/src/modules/haskell.rs
index ce0918cca..93b577d03 100644
--- a/src/modules/haskell.rs
+++ b/src/modules/haskell.rs
@@ -22,7 +22,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
&["ghc", "--", "--numeric-version", "--no-install-ghc"],
)?
.stdout;
- let formatted_version = format_haskell_version(&haskell_version)?;
+ let formatted_version = Some(format!("v{}", haskell_version.trim()))?;
let mut module = context.new_module("haskell");
let config: HaskellConfig = HaskellConfig::try_load(module.config);
@@ -34,7 +34,30 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module)
}
-fn format_haskell_version(haskell_version: &str) -> Option<String> {
- let formatted_version = format!("v{}", haskell_version.trim());
- Some(formatted_version)
+#[cfg(test)]
+mod tests {
+ use crate::modules::utils::test::render_module;
+ use ansi_term::Color;
+ use std::fs::File;
+ use std::io;
+ use tempfile;
+
+ #[test]
+ fn folder_without_stack_yaml() -> io::Result<()> {
+ let dir = tempfile::tempdir()?;
+ let actual = render_module("haskell", dir.path());
+ let expected = None;
+ assert_eq!(expected, actual);
+ Ok(())
+ }
+
+ #[test]
+ fn folder_with_stack_yaml() -> io::Result<()> {
+ let dir = tempfile::tempdir()?;
+ File::create(dir.path().join("stack.yaml"))?.sync_all()?;
+ let actual = render_module("haskell", dir.path());
+ let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
+ assert_eq!(expected, actual);
+ Ok(())
+ }
}
diff --git a/src/utils.rs b/src/utils.rs
index 7cc26e42c..eba63de80 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -43,6 +43,10 @@ pub fn exec_cmd(cmd: &str, args: &[&str]) -> Option<CommandOutput> {
stdout: String::from("0.19.1"),
stderr: String::default(),
}),
+ "stack ghc -- --numeric-version --no-install-ghc" => Some(CommandOutput {
+ stdout: String::from("8.6.5"),
+ stderr: String::default(),
+ }),
"node --version" => Some(CommandOutput {
stdout: String::from("v12.0.0"),
stderr: String::default(),
diff --git a/tests/testsuite/haskell.rs b/tests/testsuite/haskell.rs
deleted file mode 100644
index 11e90238c..000000000
--- a/tests/testsuite/haskell.rs
+++ /dev/null
@@ -1,71 +0,0 @@
-use ansi_term::Color;
-use dirs::home_dir;
-use std::fs::{File, OpenOptions};
-use std::io::{self, Write};
-use tempfile::{self, TempDir};
-
-use crate::common;
-
-#[test]
-fn folder_without_stack_yaml() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
-
- let output = common::render_module("haskell")
- .arg("--path")
- .arg(dir.path())
- .output()?;
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = "";
- assert_eq!(expected, actual);
- Ok(())
-}
-
-#[test]
-#[ignore]
-#[cfg(not(windows))]
-fn folder_with_stack_yaml() -> io::Result<()> {
- let dir = tempfile::tempdir()?;
- create_dummy_haskell_project(&dir, Some("nightly-2019-09-21 # Last GHC 8.6.5"))?;
-
- let output = if cfg!(windows) {
- let mut app_data = home_dir().unwrap();
- app_data.push("AppData");
- app_data.push("Local");
- eprintln!("{}", app_data.to_str().unwrap());
- common::render_module("haskell")
- .env("HOME", home_dir().unwrap())
- .env("LOCALAPPDATA", app_data)
- .env("STACK_ROOT", r"C:\sr")
- .arg("--path")
- .arg(dir.path())
- .output()?
- } else {
- common::render_module("haskell")
- .env("HOME", home_dir().unwrap())
- .arg("--path")
- .arg(dir.path())
- .output()?
- };
-
- let actual = String::from_utf8(output.stdout).unwrap();
-
- let expected = format!("via {} ", Color::Red.bold().paint("λ v8.6.5"));
- assert_eq!(expected, actual);
- Ok(())
-}
-
-fn create_dummy_haskell_project(folder: &TempDir, contents: Option<&str>) -> io::Result<()> {
- let cabal_path = folder.path().join("test.cabal");
- File::create(cabal_path)?.sync_all()?;
-
- let stack_yaml_path = folder.path().join("stack.yaml");
-
- let mut stack_yaml_file = OpenOptions::new()
- .write(true)
- .create(true)
- .truncate(true)
- .open(&stack_yaml_path)?;
- write!(stack_yaml_file, "resolver: {}", contents.unwrap_or(""))?;
- stack_yaml_file.sync_data()
-}
diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs
index f12b60780..8da64b56f 100644
--- a/tests/testsuite/main.rs
+++ b/tests/testsuite/main.rs
@@ -12,7 +12,6 @@ mod git_commit;
mod git_state;
mod git_status;
mod golang;
-mod haskell;
mod hg_branch;
mod hostname;
mod jobs;