Skip to content

Commit

Permalink
Tests: Add checksum/simple
Browse files Browse the repository at this point in the history
  • Loading branch information
jjensen committed Jan 22, 2016
1 parent 78ff120 commit 67aa4b3
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/checksum/simple/Jamfile.jam
@@ -0,0 +1,24 @@
#JAM_USE_CHECKSUMS = 1 ;

SubDir TOP ;

if $(NT) {
actions GenerateHeader {
type $(2:C) > $(1:C)
}
} else {
actions GenerateHeader {
cat $(2:C) > $(1:C)
}
}

local generated.h = [ C.GristFiles test : generated.h ] ;
GenerateHeader $(generated.h) : $(TOP)/template ;
Depends $(generated.h) : $(TOP)/template ;
MakeLocate $(generated.h) : $(TOP) ;
Clean clean : $(generated.h) ;
#Depends [ C.GristFiles test : main.c ] : $(g) ;

ScanContents $(generated.h) ;

C.Application test : main.c ;
7 changes: 7 additions & 0 deletions tests/checksum/simple/main.c
@@ -0,0 +1,7 @@
#include "generated.h"

int main()
{
//printf("Hello, %d\n", VALUE);
return 0;
}
1 change: 1 addition & 0 deletions tests/checksum/simple/template
@@ -0,0 +1 @@
#define VALUE 8
146 changes: 146 additions & 0 deletions tests/checksum/simple/test.lua
@@ -0,0 +1,146 @@
function TestChecksum()
local function WriteOriginalFiles()
ospath.write_file('template', [[
#define VALUE 8
]])
end

-- Test for a clean directory.
local originalFiles = {
'Jamfile.jam',
'main.c',
'template',
}

local originalDirs = {
}

-- Clean up everything.
WriteOriginalFiles()
ospath.remove('.jamcache')
RunJam{ 'clean' }
TestDirectories(originalDirs)
TestFiles(originalFiles)

---------------------------------------------------------------------------
local files
local dirs = {
'$(TOOLCHAIN_PATH)/test/',
}

local function TestNoopPattern()
local noopPattern = [[
*** found 10 target(s)...
]]
TestPattern(noopPattern, RunJam{})
TestDirectories(dirs)
TestFiles(files)
end

local patternA
local patternB
local patternC
if Platform == 'win32' then
files = {
'generated.h',
'Jamfile.jam',
'main.c',
'template',
'$(TOOLCHAIN_PATH)/test/main.obj',
'$(TOOLCHAIN_PATH)/test/test.release.exe',
'?$(TOOLCHAIN_PATH)/test/test.release.exe.intermediate.manifest',
'$(TOOLCHAIN_PATH)/test/test.release.pdb',
}

patternA = [[
*** found 21 target(s)...
*** updating 4 target(s)...
@ GenerateHeader <$(TOOLCHAIN_GRIST):test>generated.h
@ $(C_CC) <$(TOOLCHAIN_GRIST):test>main.obj
!NEXT!@ $(C_LINK) <$(TOOLCHAIN_GRIST):test>test.exe
!NEXT!*** updated 4 target(s)...
]]
else
files = {
'generated.h',
'Jamfile.jam',
'main.c',
'template',
'$(TOOLCHAIN_PATH)/test/main.o',
'$(TOOLCHAIN_PATH)/test/test.release',
}

patternA = [[
*** found 10 target(s)...
*** updating 4 target(s)...
@ GenerateHeader <$(TOOLCHAIN_GRIST):test>generated.h
@ $(C_CC) <$(TOOLCHAIN_GRIST):test>main.o
@ $(C_LINK) <$(TOOLCHAIN_GRIST):test>test
*** updated 4 target(s)...
]]
end

---------------------------------------------------------------------------
do
TestPattern(patternA, RunJam{})
TestDirectories(dirs)
TestFiles(files)
end

---------------------------------------------------------------------------
do
TestNoopPattern()
end

---------------------------------------------------------------------------
do
TestNoopPattern()
end

---------------------------------------------------------------------------
do
osprocess.sleep(1.0)
ospath.touch('template')
TestNoopPattern()
end

---------------------------------------------------------------------------
do
local pattern
if Platform == 'win32' then
pattern = [[
*** found 10 target(s)...
*** updating 3 target(s)...
@ GenerateHeader <$(TOOLCHAIN_GRIST):test>generated.h
@ $(C_CC) <$(TOOLCHAIN_GRIST):test>main.obj
!NEXT!@ $(C_LINK) <$(TOOLCHAIN_GRIST):test>test.exe
!NEXT!*** updated 3 target(s)...
]]
else
pattern = [[
*** found 10 target(s)...
*** updating 3 target(s)...
@ GenerateHeader <$(TOOLCHAIN_GRIST):test>generated.h
@ $(C_CC) <$(TOOLCHAIN_GRIST):test>main.o
*** updated 2 target(s)...
]]
end

osprocess.sleep(1.0)
ospath.write_file('template', [[
#define VALUE 10
]])
TestPattern(pattern, RunJam{})
end

---------------------------------------------------------------------------
do
TestNoopPattern()
end

---------------------------------------------------------------------------
WriteOriginalFiles()
RunJam{ 'clean' }
TestFiles(originalFiles)
TestDirectories(originalDirs)
end

0 comments on commit 67aa4b3

Please sign in to comment.