Skip to content
Permalink
Browse files

add unit test, modifies the build

  • Loading branch information...
sdpython committed Jun 14, 2018
1 parent 27b4ac2 commit 060cef291ca67b474256c54d7e76b5ef44e93958
@@ -59,13 +59,9 @@ jobs:
command: |
curl -sSL "https://packages.microsoft.com/keys/microsoft.asc" | sudo -E apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" | sudo tee -a /etc/apt/sources.list > /dev/null
echo "Done (1)"
sudo apt-get update
echo "Done (2)"
sudo -E apt-get -yq update &>> ~/apt-get-update.log
echo "Done (3)"
sudo -E apt-get -yqf --no-install-suggests --no-install-recommends --force-yes install dotnet-sdk-2.1.200
echo "Done (4)"
- run:
name: Install pandoc
@@ -146,7 +142,7 @@ jobs:
key: v3-dependencies-{{ checksum "requirements.txt" }}

- run:
name: build machinelearning
name: build machinelearning release
command: |
. venv/bin/activate
export PATH=/home/circleci/repo/clang+llvm-6.0.0-x86_64-linux-gnu-debian8/bin:$PATH
@@ -157,10 +153,33 @@ jobs:
cd ../..
- run:
name: copy binaries
name: build machinelearning debug
command: |
. venv/bin/activate
python3 setup.py copybinml
export PATH=/home/circleci/repo/clang+llvm-6.0.0-x86_64-linux-gnu-debian8/bin:$PATH
cd cscode/machinelearning
ls
bash --help
bash --verbose build.sh -Debug
cd ../..
- run:
name: copy binaries ML release
command: |
. venv/bin/activate
python3 setup.py copybinml release
- run:
name: copy binaries debug
command: |
. venv/bin/activate
python3 setup.py copybinml ML debug
- run:
name: copy binaries debug
command: |
. venv/bin/activate
python3 setup.py copybin
- run:
name: build extension
@@ -170,7 +189,27 @@ jobs:
python3 setup.py build_ext --inplace
- run:
name: run tests
name: run C# tests release
env:
DOTNET_CLI_TELEMETRY_OPTOUT:1
command: |
. venv/bin/activate
cd cscode
dotnet test -c Release TestCSharPyMLExtension
cd ..
- run:
name: run C# tests debug
env:
DOTNET_CLI_TELEMETRY_OPTOUT:1
command: |
. venv/bin/activate
cd cscode
dotnet test -c Debug TestCSharPyMLExtension
cd ..
- run:
name: run python tests
env:
DOTNET_CLI_TELEMETRY_OPTOUT:1
command: |
@@ -20,8 +20,10 @@ install:
before_script:
- cd cscode\machinelearning
- cmd /C build.cmd -Release
- cmd /C build.cmd -Debug
- cd ..\..
- python -u setup.py copybinml
- python -u setup.py copybinml debug
- python -u setup.py copybinml release
- python -u setup.py build_ext --inplace
script:
- { CMD: "python -u setup.py unittests", NAME: "UT" }
@@ -55,6 +55,7 @@ before_install:
# Set-up dll path for embedded tests
- PY_LIBDIR=$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')
- export LD_LIBRARY_PATH=$PY_LIBDIR:$LD_LIBRARY_PATH
- export DOTNET_CLI_TELEMETRY_OPTOUT=1
# Addition to pythonnet build
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
@@ -80,9 +81,16 @@ before_script:
- ls
- bash --help
- bash --verbose build.sh -Release
- bash --verbose build.sh -Debug
- cd ../..
- python setup.py copybinml
- python setup.py copybinml debug
- python setup.py copybinml release
- python setup.py copybin
- python setup.py build_ext --inplace

script:
- cd cscode
- dotnet test -c Release TestCSharPyMLExtension
- dotnet test -c Debug TestCSharPyMLExtension
- cd ..
- python setup.py unittests
@@ -35,11 +35,18 @@ before_build:
before_test:
- cd cscode\machinelearning
- build.cmd -Release
- build.cmd -Debug
- cd ..\..
- "%PYTHON%\\python -u setup.py copybinml"
- "%PYTHON%\\python -u setup.py copybinml debug"
- "%PYTHON%\\python -u setup.py copybinml release"
- "%PYTHON%\\python -u setup.py copybin"
- "%PYTHON%\\python -u setup.py build_ext --inplace"

test_script:
- cd cscode
- dotnet test -c Release TestCSharPyMLExtension
- dotnet test -c Debug TestCSharPyMLExtension
- cd ..
- "%PYTHON%\\python -u setup.py unittests"

after_test:
@@ -5,8 +5,51 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.ML">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Api">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Api.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Core">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.CpuMath">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.CpuMath.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Data">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Data.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.FastTree">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.FastTree.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.InternalStreams">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.InternalStreams.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.KMeansClustering">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.KMeansClustering.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Maml">
<HintPath>..\machinelearning\bin\AnyCPU.Release\Microsoft.ML.Maml\netstandard2.0\Microsoft.ML.Maml.dll</HintPath>
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Maml.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.PCA">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.PCA.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.StandardLearners">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.StandardLearners.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Transforms">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Transforms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Sweeper">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Sweeper.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.UniversalModelFormat">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.UniversalModelFormat.dll</HintPath>
</Reference>
</ItemGroup>

@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27703.2000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharPyMLExtension", "CSharPyMLExtension\CSharPyMLExtension.csproj", "{8031B28A-6640-4EBA-B85A-F8B66B918211}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCSharPyMLExtension", "TestCSharPyMLExtension\TestCSharPyMLExtension.csproj", "{85E33533-24CE-48F5-BE96-7A1F2F0A2DAE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{8031B28A-6640-4EBA-B85A-F8B66B918211}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8031B28A-6640-4EBA-B85A-F8B66B918211}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8031B28A-6640-4EBA-B85A-F8B66B918211}.Release|Any CPU.Build.0 = Release|Any CPU
{85E33533-24CE-48F5-BE96-7A1F2F0A2DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85E33533-24CE-48F5-BE96-7A1F2F0A2DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85E33533-24CE-48F5-BE96-7A1F2F0A2DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85E33533-24CE-48F5-BE96-7A1F2F0A2DAE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -0,0 +1,86 @@
using System;
using System.IO;
using System.Reflection;


namespace TestCSharPyMLExtension
{
public static class FileHelper
{
static bool IsRoot(string root)
{
if (!Directory.Exists(root))
return false;
var dotRoot = Path.Combine(root, "setup.py");
if (!File.Exists(dotRoot))
return false;
return true;
}

public static string GetRoot()
{
string currentDirectory = Directory.GetCurrentDirectory();
currentDirectory = Path.GetFullPath(currentDirectory);
var root = currentDirectory;
while (!string.IsNullOrEmpty(root))
{
if (IsRoot(root))
return root;
root = Path.GetDirectoryName(root);
}
throw new DirectoryNotFoundException(string.Format("Unable to find root folder from '{0}'", currentDirectory));
}

/// <summary>
/// Returns a data relative to folder data.
/// </summary>
/// <param name="name">name of the dataset</param>
/// <returns>full path of the dataset</returns>
public static string GetTestFile(string name)
{
var root = GetRoot();
var version = CSharPyMLExtension.Constants.Version();
var full = Path.Combine(root, "cscode", "TestCSharPyMLExtension", "data", name);
if (!File.Exists(full))
throw new FileNotFoundException(string.Format("Unable to find '{0}'\nFull='{1}'\nroot='{2}'\ncurrent='{3}'.",
name, full, root, Path.GetFullPath(Directory.GetCurrentDirectory())));
return full;
}


/// <summary>
/// Creates a folder where the results of the unittests should be placed.
/// </summary>
/// <param name="name">name of the output</param>
/// <param name="testFunction">name of the test</param>
/// <param name="extended">addition to make to the file</param>
/// <returns></returns>
public static string GetOutputFile(string name, string testFunction, params string[] extended)
{
#if (DEBUG)
var version = "Debug";
#else
var version = "Release";
#endif
var vers = CSharPyMLExtension.Constants.Version();
var root = GetRoot();
var tests = Path.Combine(root, "_tests");
var unittest = Path.Combine(tests, vers, version, testFunction);

if (!Directory.Exists(unittest))
Directory.CreateDirectory(unittest);

if (extended != null && extended.Length > 0)
{
var jpl = string.Join("-", extended);
unittest = Path.Combine(unittest, jpl);
if (!Directory.Exists(unittest))
Directory.CreateDirectory(unittest);
}
var full = Path.Combine(unittest, name);
if (File.Exists(full))
File.Delete(full);
return full;
}
}
}
@@ -0,0 +1,76 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CSharPyMLExtension\CSharPyMLExtension.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.ML">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Api">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Api.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Core">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.CpuMath">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.CpuMath.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Data">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Data.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.FastTree">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.FastTree.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.InternalStreams">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.InternalStreams.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.KMeansClustering">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.KMeansClustering.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Maml">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Maml.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.PCA">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.PCA.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.StandardLearners">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.StandardLearners.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Transforms">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Transforms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.Sweeper">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.Sweeper.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ML.UniversalModelFormat">
<HintPath>..\bin\machinelearning\$(Configuration)\Microsoft.ML.UniversalModelFormat.dll</HintPath>
</Reference>
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy
SourceFiles="$(SolutionDir)\bin\machinelearning\$(ConfigurationName)\CpuMathNative.dll"
DestinationFolder="$(OutDir)"
/>
<Copy
SourceFiles="$(SolutionDir)\bin\machinelearning\$(ConfigurationName)\FastTreeNative.dll"
DestinationFolder="$(OutDir)"
/>
</Target>

</Project>

0 comments on commit 060cef2

Please sign in to comment.
You can’t perform that action at this time.