<commit_before>
#include <base/uri.h>
#include <base/contract.h>
#include <base/string_util.h>
#include <base/ansi.h>
#include <base/cmd_line.h>
#include <base/scope_guard.h>
#include <base/unit_test.h>
#include <base/posix_file_system.h>
#include <sstream>
#include <iostream>

#include <unistd.h>

namespace
{

int safemain( int argc, char *argv[] )
{
	base::cmd_line options( argv[0] );

	base::unit_test fstest( "fs" );
	fstest.setup( options );

	auto errhandler = base::make_guard( [&]() { std::cerr << options << std::endl; } );
	options.add_help();
	options.parse( argc, argv );
	errhandler.dismiss();

	base::file_system::add( "file", std::make_shared<base::posix_file_system>() );

	base::uri tmppath( "file", "", "tmp", "test_posix_fs" );
	base::uri file1( tmppath, "test1" );
	base::uri file2( tmppath, "test2" );
	base::uri badpath( tmppath, "extra/bad" );
	auto fs = base::file_system::get( tmppath );

	fstest["mkdir"] = [&]( void )
	{
		try
		{
			fs->mkdir( tmppath );
			fstest.success( "mkdir successful" );
		}
		catch ( std::exception &e )
		{
			fstest.failure( "mkdir failed ({0})", e.what() );
		}

		try
		{
			fs->mkdir( badpath );
			fstest.failure( "mkdir expected to fail but did not" );
		}
		catch ( std::exception &e )
		{
			fstest.success( "mkdir failed  as expected ({0})", e.what() );
		}<commit_msg>fix filesystem test now that posix fs auto registers<commit_after>
#include <base/uri.h>
#include <base/contract.h>
#include <base/string_util.h>
#include <base/ansi.h>
#include <base/cmd_line.h>
#include <base/scope_guard.h>
#include <base/unit_test.h>
#include <base/posix_file_system.h>
#include <sstream>
#include <iostream>

#include <unistd.h>

namespace
{

int safemain( int argc, char *argv[] )
{
	base::cmd_line options( argv[0] );

	base::unit_test fstest( "fs" );
	fstest.setup( options );

	auto errhandler = base::make_guard( [&]() { std::cerr << options << std::endl; } );
	options.add_help();
	options.parse( argc, argv );
	errhandler.dismiss();

	fstest["register"] = [&]( void )
	{
		try
		{
			base::file_system::add( "file", std::make_shared<base::posix_file_system>() );
			fstest.failure( "registration succeeded, should have already defined automatically" );
		}
		catch ( std::exception &e )
		{
			fstest.success( "registration correctly failed for pre-registered fs: {0}", e.what() );
		}
	};

	base::uri tmppath( "file", "", "tmp", "test_posix_fs" );
	base::uri file1( tmppath, "test1" );
	base::uri file2( tmppath, "test2" );
	base::uri badpath( tmppath, "extra/bad" );
	auto fs = base::file_system::get( tmppath );

	fstest["mkdir"] = [&]( void )
	{
		try
		{
			fs->mkdir( tmppath );
			fstest.success( "mkdir successful" );
		}
		catch ( std::exception &e )
		{
			fstest.failure( "mkdir failed ({0})", e.what() );
		}

		try
		{
			fs->mkdir( badpath );
			fstest.failure( "mkdir expected to fail but did not" );
		}
		catch ( std::exception &e )
		{
			fstest.success( "mkdir failed  as expected ({0})", e.what() );
		}
{'fraction_non_alphanumeric': 0.18848342818881822, 'fraction_numerical': 0.0050217609641781055, 'mean_word_length': 4.223776223776224, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321939', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1162, 'n_words': 251}