Skip to content

Commit

Permalink
Repair z-applocal test bugs. (#1105)
Browse files Browse the repository at this point in the history
* Repair z-applocal test bugs.

* We accidentally checked in main.exe rather than main.cpp. Compiling main.cpp failed, but the test 'passed' because main.exe was already present.
* We never checked the output to see that vcpkg thought it actually deployed anything.
* We didn't actually test anything because we built the DLLs to be copied in the same location as the exe, so there was nothing to do.
* We wrote to the source tree.

* Also make deploying plugins from 'debug' bin dirs correct.
  • Loading branch information
BillyONeal authored Jun 22, 2023
1 parent 6391341 commit 7e3b1a7
Show file tree
Hide file tree
Showing 26 changed files with 216 additions and 110 deletions.
16 changes: 0 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,3 @@ CMakeLists.txt.user
/vcpkg-root
/CMakeUserPresets.json
/work
/azure-pipelines/e2e_projects/applocal-test/build/main.exe
/azure-pipelines/e2e_projects/applocal-test/build/main.obj
/azure-pipelines/e2e_projects/applocal-test/build/mylib.exp
/azure-pipelines/e2e_projects/applocal-test/build/mylib.dll
/azure-pipelines/e2e_projects/applocal-test/build/mylib.lib
/azure-pipelines/e2e_projects/applocal-test/build/mylib.obj
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/main.cpp
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/main.obj
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/depthengine_2_0.exp
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/depthengine_2_0.dll
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/depthengine_2_0.lib
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/depthengine_2_0.obj
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/k4a.exp
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/k4a.dll
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/k4a.lib
/azure-pipelines/e2e_projects/applocal-test/plugins/azure_kinect_sensor_sdk/k4a.obj
3 changes: 0 additions & 3 deletions azure-pipelines/e2e_projects/applocal-test/build/build.bat

This file was deleted.

8 changes: 0 additions & 8 deletions azure-pipelines/e2e_projects/applocal-test/build/main.cpp

This file was deleted.

10 changes: 0 additions & 10 deletions azure-pipelines/e2e_projects/applocal-test/build/mylib.h

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
5 changes: 5 additions & 0 deletions azure-pipelines/e2e_projects/applocal/basic/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd %~dp0
pushd installed\bin
cl /LD mylib.cpp
popd
cl /EHsc main.cpp installed\bin\mylib.lib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#define MYLIB_EXPORTS 1

#include <stdio.h>
#include "mylib.h"

void mylib::my_func() {
puts("hello world");
}
puts("hello world");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class
#if MYLIB_EXPORTS
__declspec(dllexport)
#endif
mylib {
public:
static void my_func();
};
6 changes: 6 additions & 0 deletions azure-pipelines/e2e_projects/applocal/basic/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "installed/bin/mylib.h"

int main() {
mylib::my_func();
return 0;
}
8 changes: 8 additions & 0 deletions azure-pipelines/e2e_projects/applocal/plugins-debug/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cd %~dp0
pushd installed\tools\azure-kinect-sensor-sdk
cl /LD depthengine_2_0.cpp
popd
pushd installed\debug\bin
cl /LD k4a.cpp
popd
cl /EHsc main.cpp installed/debug/bin/k4a.lib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#define MYLIB_EXPORTS 1

#include <stdio.h>
#include "k4a.h"

void k4a::my_func() {
puts("hello world");
}
puts("hello world");
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include <stdio.h>

class
class
#if MYLIB_EXPORTS
__declspec( dllexport )
__declspec(dllexport)
#endif
k4a {
public:
static void my_func();
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define MYLIB_EXPORTS 1

#include <stdio.h>
class __declspec(dllexport) depthengine_2_0 {
public:
static void my_func();
};

void depthengine_2_0::my_func() {
puts("hello world");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file exists to tell z-applocal that the azure-kinect-sensor-sdk is installed and is not
intended to be an executable PowerShell script.
6 changes: 6 additions & 0 deletions azure-pipelines/e2e_projects/applocal/plugins-debug/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "installed/debug/bin/k4a.h"

int main() {
k4a::my_func();
return 0;
}
8 changes: 8 additions & 0 deletions azure-pipelines/e2e_projects/applocal/plugins/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cd %~dp0
pushd installed\tools\azure-kinect-sensor-sdk
cl /LD depthengine_2_0.cpp
popd
pushd installed\bin
cl /LD k4a.cpp
popd
cl /EHsc main.cpp installed/bin/k4a.lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#define MYLIB_EXPORTS 1

#include <stdio.h>
#include "k4a.h"

void k4a::my_func() {
puts("hello world");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class
#if MYLIB_EXPORTS
__declspec(dllexport)
#endif
k4a {
public:
static void my_func();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#define MYLIB_EXPORTS 1

#include <stdio.h>
class __declspec(dllexport) depthengine_2_0 {
public:
static void my_func();
};

void depthengine_2_0::my_func() {
puts("hello world");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file exists to tell z-applocal that the azure-kinect-sensor-sdk is installed and is not
intended to be an executable PowerShell script.
6 changes: 6 additions & 0 deletions azure-pipelines/e2e_projects/applocal/plugins/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "installed/bin/k4a.h"

int main() {
k4a::my_func();
return 0;
}
77 changes: 60 additions & 17 deletions azure-pipelines/end-to-end-tests-dir/z-applocalcpp.ps1
Original file line number Diff line number Diff line change
@@ -1,36 +1,79 @@
if ($IsWindows) {
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

# Paths to test projects
$buildDir = "$PSScriptRoot/../e2e_projects/applocal-test/build"
$pluginsDir = "$PSScriptRoot/../e2e_projects/applocal-test/plugins"

Run-Vcpkg env "$buildDir/build.bat"
Run-Vcpkg env "$pluginsDir/azure_kinect_sensor_sdk/build.bat"

# Tests z-applocal command
Run-Vcpkg z-applocal `
--target-binary=$buildDir/main.exe `
--installed-bin-dir=$buildDir
Refresh-TestRoot
Copy-Item -Recurse -LiteralPath "$PSScriptRoot/../e2e_projects/applocal" -Destination $TestingRoot

# Tests basic z-applocal command
$basicDir = "$TestingRoot/applocal/basic"
Run-Vcpkg env "$basicDir/build.bat"
Require-FileNotExists $basicDir/mylib.dll
$applocalOutput = Run-VcpkgAndCaptureOutput z-applocal `
--target-binary=$basicDir/main.exe `
--installed-bin-dir=$basicDir/installed/bin
Throw-IfFailed
if (-Not ($applocalOutput -match '.*\\applocal\\basic\\installed\\bin\\mylib\.dll -> .*\\applocal\\basic\\mylib\.dll.*'))
{
throw "z-applocal didn't copy dependent binary"
}

Require-FileExists $basicDir/mylib.dll

# Tests z-applocal command with no arguments
Run-Vcpkg z-applocal
Throw-IfNotFailed

# Tests z-applocal with no installed-bin-dir argument
Run-Vcpkg z-applocal `
--target-binary=$buildDir/main.exe
--target-binary=$basicDir/main.exe
Throw-IfNotFailed

# Tests z-applocal with no target-binary argument
Run-Vcpkg z-applocal `
--installed-bin-dir=$buildDir
--installed-bin-dir=$basicDir
Throw-IfNotFailed

# Tests deploy azure kinect sensor SDK plugins
Run-Vcpkg z-applocal `
--target-binary=$pluginsDir/azure_kinect_sensor_sdk/main.exe `
--installed-bin-dir=$pluginsDir/azure_kinect_sensor_sdk
Throw-IfFailed
$pluginsDir = "$TestingRoot/applocal/plugins"
Run-Vcpkg env "$pluginsDir/build.bat"
Require-FileNotExists "$pluginsDir/k4a.dll"
Require-FileNotExists "$pluginsDir/depthengine_2_0.dll"
$applocalOutput = Run-VcpkgAndCaptureOutput z-applocal `
--target-binary=$pluginsDir/main.exe `
--installed-bin-dir=$pluginsDir/installed/bin
Throw-IfFailed
if (-Not ($applocalOutput -match '.*\\applocal\\plugins\\installed\\bin\\k4a\.dll -> .*\\applocal\\plugins\\k4a\.dll.*'))
{
throw "z-applocal didn't copy dependent binary"
}

if (-Not ($applocalOutput -match '.*\\applocal\\plugins\\installed\\tools\\azure-kinect-sensor-sdk\\depthengine_2_0\.dll -> .*\\applocal\\plugins\\depthengine_2_0\.dll.*'))
{
throw "z-applocal didn't copy xbox plugins"
}

Require-FileExists "$pluginsDir/k4a.dll"
Require-FileExists "$pluginsDir/depthengine_2_0.dll"

# Tests deploy azure kinect sensor SDK plugins from debug directories
$pluginsDebugDir = "$TestingRoot/applocal/plugins-debug"
Run-Vcpkg env "$pluginsDebugDir/build.bat"
Require-FileNotExists "$pluginsDebugDir/k4a.dll"
Require-FileNotExists "$pluginsDebugDir/depthengine_2_0.dll"
$applocalOutput = Run-VcpkgAndCaptureOutput z-applocal `
--target-binary=$pluginsDebugDir/main.exe `
--installed-bin-dir=$pluginsDebugDir/installed/debug/bin
Throw-IfFailed
if (-Not ($applocalOutput -match '.*\\applocal\\plugins-debug\\installed\\debug\\bin\\k4a\.dll -> .*\\applocal\\plugins-debug\\k4a\.dll.*'))
{
throw "z-applocal didn't copy dependent debug binary"
}

if (-Not ($applocalOutput -match '.*\\applocal\\plugins-debug\\installed\\tools\\azure-kinect-sensor-sdk\\depthengine_2_0\.dll -> .*\\applocal\\plugins-debug\\depthengine_2_0\.dll.*'))
{
throw "z-applocal didn't copy xbox plugins"
}

Require-FileExists "$pluginsDir/k4a.dll"
Require-FileExists "$pluginsDir/depthengine_2_0.dll"
}
Loading

0 comments on commit 7e3b1a7

Please sign in to comment.