<commit_before>
module Main where

import Control.Monad
import Data.List
import Data.Maybe
import System.Cmd
import System.Environment
import System.Exit

import Development.NSIS
import Examples.Example1
import Examples.Example2
import Examples.Primes


examples = let (*) = (,) in ["example1" * example1, "example2" * example2, "primes" * primes]


main = do
    args <- getArgs
    let (flags,names) = partition ("-" `isPrefixOf`) args
    names <- return $ concatMap (\x -> if x == "all" then map fst examples else [x]) names
    if null names then
        putStrLn $ "Type the name of an example: " ++ unwords (map fst examples)
     else do
        forM_ names $ \name -> do
            let script = fromMaybe (error $ "Unknown example: " ++ name) $ lookup name examples
            unless ("--nowrite" `elem` flags) $ writeFile (name ++ ".nsi") $ nsis script
            unless ("--nobuild" `elem` flags) $ do
                r <- system $ "\"C:/Program Files/NSIS/makensis.exe\" " ++ name ++ ".nsi"
                when (r /= ExitSuccess) $ error "NSIS FAILED"
            when ("--run" `elem` flags) $ do
                system $ name ++ ".exe"
                return ()<commit_msg>Rewrite the test script, ensure the default just works for the test routine<commit_after>
module Main where

import Control.Monad
import Data.List
import Data.Maybe
import System.Cmd
import System.Environment
import System.Exit
import System.Info

import Development.NSIS
import Examples.Example1
import Examples.Example2
import Examples.Primes


examples = let (*) = (,) in ["example1" * example1, "example2" * example2, "primes" * primes]


main = do
    args <- getArgs
    let (flags,names) = partition ("-" `isPrefixOf`) args
    when ("--help" `elem` flags) $ do
        putStr $ unlines
            ["nsis-test [FLAGS] [EXAMPLES]"
            ,"Examples:"
            ,"  " ++ unwords (map fst examples)
            ,"Flags:"
            ,"  --help     Show this message"
            ,"  --nowrite  Don't write out the scripts"
            ,"  --nobuild  Don't build"
            ,"  --run      Run the result"
            ]
        exitSuccess
    when (null args) $ do
        putStrLn "*****************************************************************"
        putStrLn "** Running nsis test suite, run with '--help' to see arguments **"
        putStrLn "*****************************************************************"
    names <- return $ if null names then map fst examples else names
    forM_ names $ \name -> do
        let script = fromMaybe (error $ "Unknown example: " ++ name) $ lookup name examples
        unless ("--nowrite" `elem` flags) $ writeFile (name ++ ".nsi") $ nsis script
        unless ("--nobuild" `elem` flags) $
            if os == "mingw32" then do
                r <- system $ "makensis " ++ name ++ ".nsi"
                when (r /= ExitSuccess) $ error "NSIS FAILED"
            else
                putStrLn "Not building because not on Windows"
        when ("--run" `elem` flags) $ do
            system $ name ++ ".exe"
            return ()
{'fraction_non_alphanumeric': 0.16028552887735237, 'fraction_numerical': 0.004542504866969501, 'mean_word_length': 2.2763018065887355, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '427012', 'n_tokens_mistral': 889, 'n_tokens_neox': 844, 'n_words': 300}